mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-24 20:48:34 +01:00
Compare commits
3 commits
559c4165e8
...
65cce7fae5
Author | SHA1 | Date | |
---|---|---|---|
65cce7fae5 | |||
24cf4ae186 | |||
584514944b |
199 changed files with 3538 additions and 3630 deletions
|
@ -23,6 +23,7 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
@ -51,7 +52,7 @@ import java.util.function.Predicate;
|
|||
|
||||
public final class Helper {
|
||||
|
||||
public static boolean getBlockEntitiesInArea(Level level, BlockPos pos, int radius, Function<BlockEntity, Boolean> consumer) {
|
||||
public static boolean getBlockEntitiesInArea(LevelAccessor level, BlockPos pos, int radius, Function<BlockEntity, Boolean> consumer) {
|
||||
for (var x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) {
|
||||
for (var z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) {
|
||||
var chunk = getLoadedChunk(level, x, z);
|
||||
|
@ -89,7 +90,7 @@ public final class Helper {
|
|||
return frames;
|
||||
}
|
||||
|
||||
public static LevelChunk getLoadedChunk(Level level, int x, int z) {
|
||||
public static LevelChunk getLoadedChunk(LevelAccessor level, int x, int z) {
|
||||
// DO NOT EDIT PLEASE FOR THE LOVE OF GOD
|
||||
// This is very finicky and easily causes the game to hang for some reason
|
||||
var provider = level.getChunkSource();
|
||||
|
|
|
@ -39,9 +39,9 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) {
|
||||
if (extract && player.isCreative())
|
||||
return true;
|
||||
ItemStack stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.capAuraContainer).isPresent(), player);
|
||||
var stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.capAuraContainer).isPresent(), player);
|
||||
if (!stack.isEmpty()) {
|
||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
|
||||
var container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
|
||||
if (extract) {
|
||||
amount -= container.drainAura(amount, simulate);
|
||||
} else {
|
||||
|
@ -59,8 +59,8 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public void spawnParticleStream(float startX, float startY, float startZ, float endX, float endY, float endZ, float speed, int color, float scale) {
|
||||
Vec3 dir = new Vec3(endX - startX, endY - startY, endZ - startZ);
|
||||
double length = dir.length();
|
||||
var dir = new Vec3(endX - startX, endY - startY, endZ - startZ);
|
||||
var length = dir.length();
|
||||
if (length > 0) {
|
||||
dir = dir.normalize();
|
||||
this.spawnMagicParticle(startX, startY, startZ,
|
||||
|
@ -92,7 +92,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
@Override
|
||||
public List<Tuple<Vec3, Integer>> getActiveEffectPowders(Level level, AABB area, ResourceLocation name) {
|
||||
List<Tuple<Vec3, Integer>> found = new ArrayList<>();
|
||||
for (Tuple<Vec3, Integer> powder : ((LevelData) ILevelData.getLevelData(level)).effectPowders.get(name))
|
||||
for (var powder : ((LevelData) ILevelData.getLevelData(level)).effectPowders.get(name))
|
||||
if (area.contains(powder.getA()))
|
||||
found.add(powder);
|
||||
return found;
|
||||
|
@ -100,10 +100,10 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public boolean isEffectPowderActive(Level level, BlockPos pos, ResourceLocation name) {
|
||||
Vec3 posVec = new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
List<Tuple<Vec3, Integer>> powders = this.getActiveEffectPowders(level, new AABB(pos).inflate(64), name);
|
||||
for (Tuple<Vec3, Integer> powder : powders) {
|
||||
AABB bounds = Helper.aabb(powder.getA()).inflate(powder.getB());
|
||||
var posVec = new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
var powders = this.getActiveEffectPowders(level, new AABB(pos).inflate(64), name);
|
||||
for (var powder : powders) {
|
||||
var bounds = Helper.aabb(powder.getA()).inflate(powder.getB());
|
||||
if (bounds.contains(posVec))
|
||||
return true;
|
||||
}
|
||||
|
@ -117,22 +117,22 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public int getSpotAmountInArea(Level level, BlockPos pos, int radius) {
|
||||
MutableInt result = new MutableInt();
|
||||
var result = new MutableInt();
|
||||
this.getAuraSpotsInArea(level, pos, radius, (blockpos, drainSpot) -> result.increment());
|
||||
return result.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAuraInArea(Level level, BlockPos pos, int radius) {
|
||||
MutableInt result = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||
var result = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot));
|
||||
return result.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius) {
|
||||
MutableInt spots = new MutableInt();
|
||||
MutableInt aura = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||
var spots = new MutableInt();
|
||||
var aura = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> {
|
||||
aura.add(drainSpot);
|
||||
spots.increment();
|
||||
|
@ -142,9 +142,9 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public int triangulateAuraInArea(Level level, BlockPos pos, int radius) {
|
||||
MutableFloat result = new MutableFloat(IAuraChunk.DEFAULT_AURA);
|
||||
var result = new MutableFloat(IAuraChunk.DEFAULT_AURA);
|
||||
IAuraChunk.getSpotsInArea(level, pos, radius, (blockPos, spot) -> {
|
||||
float percentage = 1F - (float) Math.sqrt(pos.distSqr(blockPos)) / radius;
|
||||
var percentage = 1F - (float) Math.sqrt(pos.distSqr(blockPos)) / radius;
|
||||
result.add(spot * percentage);
|
||||
});
|
||||
return result.intValue();
|
||||
|
@ -152,15 +152,15 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public BlockPos getLowestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) {
|
||||
MutableInt lowestAmount = new MutableInt(Integer.MAX_VALUE);
|
||||
MutableObject<BlockPos> lowestSpot = new MutableObject<>();
|
||||
var lowestAmount = new MutableInt(Integer.MAX_VALUE);
|
||||
var lowestSpot = new MutableObject<BlockPos>();
|
||||
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> {
|
||||
if (drainSpot < lowestAmount.intValue()) {
|
||||
lowestAmount.setValue(drainSpot);
|
||||
lowestSpot.setValue(blockPos);
|
||||
}
|
||||
});
|
||||
BlockPos lowest = lowestSpot.getValue();
|
||||
var lowest = lowestSpot.getValue();
|
||||
if (lowest == null || lowestAmount.intValue() >= 0)
|
||||
lowest = defaultSpot;
|
||||
return lowest;
|
||||
|
@ -168,15 +168,15 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public BlockPos getHighestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) {
|
||||
MutableInt highestAmount = new MutableInt(Integer.MIN_VALUE);
|
||||
MutableObject<BlockPos> highestSpot = new MutableObject<>();
|
||||
var highestAmount = new MutableInt(Integer.MIN_VALUE);
|
||||
var highestSpot = new MutableObject<BlockPos>();
|
||||
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> {
|
||||
if (drainSpot > highestAmount.intValue()) {
|
||||
highestAmount.setValue(drainSpot);
|
||||
highestSpot.setValue(blockPos);
|
||||
}
|
||||
});
|
||||
BlockPos highest = highestSpot.getValue();
|
||||
var highest = highestSpot.getValue();
|
||||
if (highest == null || highestAmount.intValue() <= 0)
|
||||
highest = defaultSpot;
|
||||
return highest;
|
||||
|
|
|
@ -182,7 +182,7 @@ public final class ModConfig {
|
|||
|
||||
try {
|
||||
for (String s : this.additionalBotanistPickaxeConversions.get()) {
|
||||
String[] split = s.split("->");
|
||||
var split = s.split("->");
|
||||
NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put(
|
||||
Objects.requireNonNull(Helper.getStateFromString(split[0]), "state1"),
|
||||
Objects.requireNonNull(Helper.getStateFromString(split[1]), "state2"));
|
||||
|
@ -193,9 +193,9 @@ public final class ModConfig {
|
|||
|
||||
try {
|
||||
for (String s : this.auraTypeOverrides.get()) {
|
||||
String[] split = s.split("->");
|
||||
ResourceLocation dim = new ResourceLocation(split[0]);
|
||||
BasicAuraType type = Objects.requireNonNull((BasicAuraType) NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1])), "type");
|
||||
var split = s.split("->");
|
||||
var dim = new ResourceLocation(split[0]);
|
||||
var type = Objects.requireNonNull((BasicAuraType) NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1])), "type");
|
||||
type.addDimensionType(dim);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -204,9 +204,9 @@ public final class ModConfig {
|
|||
|
||||
try {
|
||||
for (String s : this.additionalOres.get()) {
|
||||
String[] split = s.split("->");
|
||||
WeightedOre ore = new WeightedOre(new ResourceLocation(split[0]), Integer.parseInt(split[1]));
|
||||
String dimension = split[2];
|
||||
var split = s.split("->");
|
||||
var ore = new WeightedOre(new ResourceLocation(split[0]), Integer.parseInt(split[1]));
|
||||
var dimension = split[2];
|
||||
if ("nether".equalsIgnoreCase(dimension)) {
|
||||
NaturesAuraAPI.NETHER_ORES.removeIf(o -> o.tag.equals(ore.tag));
|
||||
NaturesAuraAPI.NETHER_ORES.add(ore);
|
||||
|
@ -230,10 +230,10 @@ public final class ModConfig {
|
|||
|
||||
try {
|
||||
for (String s : this.additionalProjectiles.get()) {
|
||||
String[] split = s.split("->");
|
||||
ResourceLocation name = new ResourceLocation(split[0]);
|
||||
EntityType<?> type = Objects.requireNonNull(ForgeRegistries.ENTITIES.getValue(name));
|
||||
int amount = Integer.parseInt(split[1]);
|
||||
var split = s.split("->");
|
||||
var name = new ResourceLocation(split[0]);
|
||||
var type = Objects.requireNonNull(ForgeRegistries.ENTITIES.getValue(name));
|
||||
var amount = Integer.parseInt(split[1]);
|
||||
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(type, amount);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -2,10 +2,6 @@ package de.ellpeck.naturesaura;
|
|||
|
||||
import com.google.common.base.Strings;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
|
@ -49,7 +45,7 @@ public final class NaturesAura {
|
|||
instance = this;
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
|
||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||
var builder = new ForgeConfigSpec.Builder();
|
||||
ModConfig.instance = new ModConfig(builder);
|
||||
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, builder.build());
|
||||
}
|
||||
|
@ -61,11 +57,6 @@ public final class NaturesAura {
|
|||
}
|
||||
|
||||
private void preInit(FMLCommonSetupEvent event) {
|
||||
Helper.registerCap(IAuraContainer.class);
|
||||
Helper.registerCap(IAuraRecharge.class);
|
||||
Helper.registerCap(IAuraChunk.class);
|
||||
Helper.registerCap(ILevelData.class);
|
||||
|
||||
Compat.setup(event);
|
||||
PacketHandler.init();
|
||||
new Multiblocks();
|
||||
|
|
|
@ -35,7 +35,7 @@ public interface IAuraChunk extends INBTSerializable<CompoundTag> {
|
|||
* @return The {@link IAuraChunk} instance belonging to the chunk
|
||||
*/
|
||||
static IAuraChunk getAuraChunk(Level level, BlockPos pos) {
|
||||
LevelChunk chunk = (LevelChunk) level.getChunk(pos);
|
||||
var chunk = (LevelChunk) level.getChunk(pos);
|
||||
return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class BasicAuraContainer implements IAuraContainer {
|
|||
|
||||
@Override
|
||||
public int storeAura(int amountToStore, boolean simulate) {
|
||||
int actual = Math.min(amountToStore, this.maxAura - this.aura);
|
||||
var actual = Math.min(amountToStore, this.maxAura - this.aura);
|
||||
if (!simulate) {
|
||||
this.aura += actual;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class BasicAuraContainer implements IAuraContainer {
|
|||
|
||||
@Override
|
||||
public int drainAura(int amountToDrain, boolean simulate) {
|
||||
int actual = Math.min(amountToDrain, this.aura);
|
||||
var actual = Math.min(amountToDrain, this.aura);
|
||||
if (!simulate) {
|
||||
this.aura -= actual;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ public class ItemAuraContainer implements IAuraContainer {
|
|||
|
||||
@Override
|
||||
public int storeAura(int amountToStore, boolean simulate) {
|
||||
int aura = this.getStoredAura();
|
||||
int actual = Math.min(amountToStore, this.getMaxAura() - aura);
|
||||
var aura = this.getStoredAura();
|
||||
var actual = Math.min(amountToStore, this.getMaxAura() - aura);
|
||||
if (!simulate) {
|
||||
this.setAura(aura + actual);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class ItemAuraContainer implements IAuraContainer {
|
|||
|
||||
@Override
|
||||
public int drainAura(int amountToDrain, boolean simulate) {
|
||||
int aura = this.getStoredAura();
|
||||
int actual = Math.min(amountToDrain, aura);
|
||||
var aura = this.getStoredAura();
|
||||
var actual = Math.min(amountToDrain, aura);
|
||||
if (!simulate) {
|
||||
this.setAura(aura - actual);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public interface IAuraType {
|
|||
|
||||
static IAuraType forLevel(Level level) {
|
||||
IAuraType highestType = NaturesAuraAPI.TYPE_OTHER;
|
||||
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values())
|
||||
for (var type : NaturesAuraAPI.AURA_TYPES.values())
|
||||
if (type.isPresentInLevel(level) && type.getPriority() > highestType.getPriority())
|
||||
highestType = type;
|
||||
return highestType;
|
||||
|
|
|
@ -4,26 +4,26 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAncientLeaves;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
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.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorProvidingBlock, IColorProvidingItem, ICustomBlockState {
|
||||
public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorProvidingBlock, IColorProvidingItem, ICustomBlockState, EntityBlock {
|
||||
|
||||
public BlockAncientLeaves() {
|
||||
super(Block.Properties.of(Material.LEAVES, MaterialColor.COLOR_PINK).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS));
|
||||
|
@ -36,26 +36,15 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
return "ancient_leaves";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockState state, IBlockReader level) {
|
||||
return new BlockEntityAncientLeaves();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBlockEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IBlockColor getBlockColor() {
|
||||
public BlockColor getBlockColor() {
|
||||
return (state, levelIn, pos, tintIndex) -> 0xE55B97;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IItemColor getItemColor() {
|
||||
public ItemColor getItemColor() {
|
||||
return (stack, tintIndex) -> 0xE55B97;
|
||||
}
|
||||
|
||||
|
@ -63,8 +52,8 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
super.animateTick(stateIn, levelIn, pos, rand);
|
||||
if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.down()).isOpaqueCube(levelIn, pos)) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.below()).isCollisionShapeFullBlock(levelIn, pos)) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAncientLeaves) {
|
||||
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
|
@ -83,17 +72,17 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
|
||||
super.randomTick(state, levelIn, pos, random);
|
||||
if (!levelIn.isClientSide) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAncientLeaves) {
|
||||
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() <= 0) {
|
||||
levelIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState());
|
||||
levelIn.setBlockAndUpdate(pos, ModBlocks.DECAYED_LEAVES.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ticksRandomly(BlockState state) {
|
||||
public boolean isRandomlyTicking(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,4 +90,10 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockEntityAncientLeaves(pos, state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.block.RotatedPillarBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.material.MaterialColor;
|
||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
|
||||
public class BlockAncientLog extends RotatedPillarBlock implements IModItem, ICustomBlockState {
|
||||
|
||||
private final String baseName;
|
||||
|
||||
public BlockAncientLog(String baseName) {
|
||||
super(Properties.create(Material.WOOD, MaterialColor.PURPLE).hardnessAndResistance(2.0F).sound(SoundType.WOOD));
|
||||
super(Properties.of(Material.WOOD, MaterialColor.COLOR_PURPLE).strength(2.0F).sound(SoundType.WOOD));
|
||||
this.baseName = baseName;
|
||||
ModRegistry.add(this);
|
||||
}
|
||||
|
|
|
@ -3,33 +3,34 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||
import de.ellpeck.naturesaura.gen.LevelGenAncientTree;
|
||||
import de.ellpeck.naturesaura.reg.*;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockAncientSapling extends BushBlock implements IGrowable, IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType {
|
||||
protected static final VoxelShape SHAPE = Block.makeCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
||||
public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType {
|
||||
|
||||
protected static final VoxelShape SHAPE = box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
||||
|
||||
public BlockAncientSapling() {
|
||||
super(Properties.create(Material.PLANTS).hardnessAndResistance(0.0F).sound(SoundType.PLANT));
|
||||
super(Properties.of(Material.GRASS).strength(0.0F).sound(SoundType.GRASS));
|
||||
ModRegistry.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
|
@ -38,9 +39,8 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
if (!level.isClientSide) {
|
||||
super.randomTick(state, level, pos, random);
|
||||
|
||||
if (level.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) {
|
||||
this.grow(level, random, pos, state);
|
||||
}
|
||||
if (level.getLightEmission(pos.above()) >= 9 && random.nextInt(7) == 0)
|
||||
this.performBonemeal(level, random, pos, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,26 +50,26 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(SaplingBlock.STAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGrow(IBlockReader levelIn, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(BlockGetter p_50897_, BlockPos p_50898_, BlockState p_50899_, boolean p_50900_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseBonemeal(Level level, Random rand, BlockPos pos, BlockState state) {
|
||||
return level.rand.nextFloat() < 0.45F;
|
||||
public boolean isBonemealSuccess(Level level, Random rand, BlockPos pos, BlockState state) {
|
||||
return level.random.nextFloat() < 0.45F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
|
||||
if (state.get(SaplingBlock.STAGE) == 0) {
|
||||
level.setBlockState(pos, state.func_235896_a_(SaplingBlock.STAGE), 4);
|
||||
public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
|
||||
if (state.getValue(SaplingBlock.STAGE) == 0) {
|
||||
level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4);
|
||||
} else if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) {
|
||||
ModFeatures.ANCIENT_TREE.func_241855_a(level, level.getChunkProvider().getChunkGenerator(), rand, pos, LevelGenAncientTree.CONFIG);
|
||||
ModFeatures.Configured.ANCIENT_TREE.place(level, level.getChunkSource().getGenerator(), rand, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,6 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutoutMipped;
|
||||
return RenderType::cutoutMipped;
|
||||
}
|
||||
}
|
|
@ -4,24 +4,23 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalContainer;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(5, 0, 5, 11, 13, 11);
|
||||
private static final VoxelShape SHAPE = box(5, 0, 5, 11, 13, 11);
|
||||
|
||||
public BlockAnimalContainer() {
|
||||
super("animal_container", BlockEntityAnimalContainer::new, Properties.from(Blocks.STONE));
|
||||
super("animal_container", BlockEntityAnimalContainer::new, Properties.copy(Blocks.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,18 +29,18 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAnimalContainer) {
|
||||
int radius = ((BlockEntityAnimalContainer) tile).getRadius();
|
||||
var radius = ((BlockEntityAnimalContainer) tile).getRadius();
|
||||
if (radius > 0)
|
||||
return new AxisAlignedBB(pos).grow(radius);
|
||||
return new AABB(pos).inflate(radius);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,17 +8,17 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.INPC;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Mth;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.npc.Npc;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -29,53 +29,53 @@ import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockAnimalGenerator() {
|
||||
super("animal_generator", BlockEntityAnimalGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
|
||||
super("animal_generator", BlockEntityAnimalGenerator::new, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
if (entity.level.isClientSide || entity.level.getGameTime() % 40 != 0 || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC)
|
||||
var entity = event.getEntityLiving();
|
||||
if (entity.level.isClientSide || entity.level.getGameTime() % 40 != 0 || !(entity instanceof Animal) || entity instanceof Mob || entity instanceof Npc)
|
||||
return;
|
||||
CompoundTag data = entity.getPersistentData();
|
||||
int timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive");
|
||||
var data = entity.getPersistentData();
|
||||
var timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive");
|
||||
data.putInt(NaturesAura.MOD_ID + ":time_alive", timeAlive + 40);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityDeath(LivingDeathEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
if (entity.level.isClientSide || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC)
|
||||
var entity = event.getEntityLiving();
|
||||
if (entity.level.isClientSide || !(entity instanceof Animal) || entity instanceof Mob || entity instanceof Npc)
|
||||
return;
|
||||
BlockPos pos = entity.getPosition();
|
||||
var pos = entity.blockPosition();
|
||||
Helper.getBlockEntitiesInArea(entity.level, pos, 5, tile -> {
|
||||
if (!(tile instanceof BlockEntityAnimalGenerator))
|
||||
if (!(tile instanceof BlockEntityAnimalGenerator gen))
|
||||
return false;
|
||||
BlockEntityAnimalGenerator gen = (BlockEntityAnimalGenerator) tile;
|
||||
|
||||
CompoundTag data = entity.getPersistentData();
|
||||
var data = entity.getPersistentData();
|
||||
data.putBoolean(NaturesAura.MOD_ID + ":no_drops", true);
|
||||
|
||||
if (gen.isBusy())
|
||||
return false;
|
||||
|
||||
boolean child = entity.isChild();
|
||||
float timeMod = child ? 0.5F : 1;
|
||||
float amountMod = child ? 0.667F : 1;
|
||||
var child = entity.isBaby();
|
||||
var timeMod = child ? 0.5F : 1;
|
||||
var amountMod = child ? 0.667F : 1;
|
||||
|
||||
int timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive");
|
||||
int time = Math.min(Mth.floor((timeAlive - 15000) / 500F * timeMod), 200);
|
||||
int amount = Math.min(Mth.floor((timeAlive - 8000) / 2F * amountMod), 25000);
|
||||
var timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive");
|
||||
var time = Math.min(Mth.floor((timeAlive - 15000) / 500F * timeMod), 200);
|
||||
var amount = Math.min(Mth.floor((timeAlive - 8000) / 2F * amountMod), 25000);
|
||||
if (time <= 0 || amount <= 0)
|
||||
return false;
|
||||
gen.setGenerationValues(time, amount);
|
||||
|
||||
BlockPos genPos = gen.getPos();
|
||||
var genPos = gen.getBlockPos();
|
||||
PacketHandler.sendToAllAround(entity.level, pos, 32, new PacketParticles(
|
||||
(float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME,
|
||||
(float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME,
|
||||
child ? 1 : 0,
|
||||
(int) (entity.getEyeHeight() * 10F),
|
||||
genPos.getX(), genPos.getY(), genPos.getZ()));
|
||||
|
@ -86,22 +86,22 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
|
|||
|
||||
@SubscribeEvent
|
||||
public void onEntityDrops(LivingDropsEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
var entity = event.getEntityLiving();
|
||||
if (entity.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":no_drops"))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityExp(LivingExperienceDropEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
var entity = event.getEntityLiving();
|
||||
if (entity.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":no_drops"))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(5);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalSpawner;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public class BlockAnimalSpawner extends BlockContainerImpl {
|
||||
|
||||
public BlockAnimalSpawner() {
|
||||
super("animal_spawner", BlockEntityAnimalSpawner::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
||||
super("animal_spawner", BlockEntityAnimalSpawner::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
|||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader levelIn, BlockPos pos) {
|
||||
BlockPos down = pos.below();
|
||||
var down = pos.below();
|
||||
return this.mayPlaceOn(levelIn.getBlockState(down), levelIn, down);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
|||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
Vec3 vec3d = state.getOffset(levelIn, pos);
|
||||
var vec3d = state.getOffset(levelIn, pos);
|
||||
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,6 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
|||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockEntityAuraBloom();
|
||||
return new BlockEntityAuraBloom(pos, state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraDetector;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.material.Material;
|
||||
|
||||
public class BlockAuraDetector extends BlockContainerImpl {
|
||||
|
||||
public BlockAuraDetector() {
|
||||
super("aura_detector", BlockEntityAuraDetector::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
||||
super("aura_detector", BlockEntityAuraDetector::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAuraDetector)
|
||||
return ((BlockEntityAuraDetector) tile).redstonePower;
|
||||
public int getAnalogOutputSignal(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAuraDetector detector)
|
||||
return detector.redstonePower;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,48 +1,42 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderAuraTimer;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.BlockEntityType;
|
||||
import net.minecraft.util.InteractionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider<BlockEntityAuraTimer>, ICustomRenderType {
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(1, 0, 1, 15, 15, 15);
|
||||
private static final VoxelShape SHAPE = box(1, 0, 1, 15, 15, 15);
|
||||
|
||||
public BlockAuraTimer() {
|
||||
super("aura_timer", BlockEntityAuraTimer::new, Properties.from(Blocks.SMOOTH_STONE));
|
||||
this.setDefaultState(this.getDefaultState().with(BlockStateProperties.POWERED, false));
|
||||
super("aura_timer", BlockEntityAuraTimer::new, Properties.copy(Blocks.SMOOTH_STONE));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(BlockStateProperties.POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,46 +45,44 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public Tuple<BlockEntityType<BlockEntityAuraTimer>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityAuraTimer>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.AURA_TIMER, () -> RenderAuraTimer::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutout;
|
||||
return RenderType::cutout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(BlockStateProperties.POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult p_225533_6_) {
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult p_225533_6_) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower(BlockState state) {
|
||||
public boolean isSignalSource(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakPower(BlockState state, IBlockReader level, BlockPos pos, Direction side) {
|
||||
return state.get(BlockStateProperties.POWERED) ? 15 : 0;
|
||||
public int getSignal(BlockState state, BlockGetter level, BlockPos pos, Direction side) {
|
||||
return state.getValue(BlockStateProperties.POWERED) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
|
||||
super.tick(state, levelIn, pos, random);
|
||||
if (state.get(BlockStateProperties.POWERED))
|
||||
levelIn.setBlockState(pos, state.with(BlockStateProperties.POWERED, false));
|
||||
if (state.getValue(BlockStateProperties.POWERED))
|
||||
levelIn.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.AURA_TIMER, RenderAuraTimer::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,31 +3,32 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAutoCrafter;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
public BlockAutoCrafter() {
|
||||
super("auto_crafter", BlockEntityAutoCrafter::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD));
|
||||
super("auto_crafter", BlockEntityAutoCrafter::new, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return super.getStateForPlacement(context).with(FACING, context.getPlayer().getHorizontalFacing());
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return super.getStateForPlacement(context).setValue(FACING, context.getPlayer().getDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,25 +3,26 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityBlastFurnaceBooster;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICustomBlockState {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
private static final VoxelShape SHAPE = Shapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F);
|
||||
|
||||
public BlockBlastFurnaceBooster() {
|
||||
super("blast_furnace_booster", BlockEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE).setLightLevel(s -> 0));
|
||||
super("blast_furnace_booster", BlockEntityBlastFurnaceBooster::new, Block.Properties.copy(Blocks.BLAST_FURNACE).lightLevel(s -> 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,19 +31,19 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return super.getStateForPlacement(context).with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return super.getStateForPlacement(context).setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,29 +4,30 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
||||
public class BlockCatalyst extends BlockImpl implements ICustomBlockState {
|
||||
|
||||
public static final BooleanProperty NETHER = BlockNatureAltar.NETHER;
|
||||
|
||||
public BlockCatalyst(String baseName, Properties properties) {
|
||||
super(baseName, properties);
|
||||
this.setDefaultState(this.getDefaultState().with(NETHER, false));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
return super.getStateForPlacement(context).with(NETHER, nether);
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
return super.getStateForPlacement(context).setValue(NETHER, nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(NETHER);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityChorusGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
public class BlockChorusGenerator extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockChorusGenerator() {
|
||||
super("chorus_generator", BlockEntityChorusGenerator::new, Properties.from(Blocks.END_STONE));
|
||||
super("chorus_generator", BlockEntityChorusGenerator::new, Properties.copy(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,33 +7,28 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityChunkLoader;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Mth;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12);
|
||||
private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12);
|
||||
|
||||
public BlockChunkLoader() {
|
||||
super("chunk_loader", BlockEntityChunkLoader::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
|
||||
super("chunk_loader", BlockEntityChunkLoader::new, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,12 +38,12 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityChunkLoader) {
|
||||
int range = ((BlockEntityChunkLoader) tile).range();
|
||||
var range = ((BlockEntityChunkLoader) tile).range();
|
||||
if (range > 0) {
|
||||
return new AxisAlignedBB(
|
||||
return new AABB(
|
||||
(pos.getX() - range) >> 4 << 4,
|
||||
0,
|
||||
(pos.getZ() - range) >> 4 << 4,
|
||||
|
@ -65,13 +60,13 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
|||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
if (!ModConfig.instance.chunkLoader.get())
|
||||
return;
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityChunkLoader) {
|
||||
int range = ((BlockEntityChunkLoader) tile).range();
|
||||
for (int i = Mth.ceil(range / 8F); i > 0; i--) {
|
||||
var range = ((BlockEntityChunkLoader) tile).range();
|
||||
for (var i = Mth.ceil(range / 8F); i > 0; i--) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
pos.getX() + levelIn.rand.nextFloat(), pos.getY() + levelIn.rand.nextFloat(), pos.getZ() + levelIn.rand.nextFloat(),
|
||||
0, 0, 0, 0xa12dff, 1F + levelIn.rand.nextFloat(), 100, 0, false, true);
|
||||
pos.getX() + levelIn.random.nextFloat(), pos.getY() + levelIn.random.nextFloat(), pos.getZ() + levelIn.random.nextFloat(),
|
||||
0, 0, 0, 0xa12dff, 1F + levelIn.random.nextFloat(), 100, 0, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,18 +78,13 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return ModConfig.instance.chunkLoader.get() ? super.getTranslationKey() : "block." + NaturesAura.MOD_ID + "." + this.getBaseName() + ".disabled";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable IBlockReader levelIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
super.addInformation(stack, levelIn, tooltip, flagIn);
|
||||
public String getDescriptionId() {
|
||||
return ModConfig.instance.chunkLoader.get() ? super.getDescriptionId() : "block." + NaturesAura.MOD_ID + "." + this.getBaseName() + ".disabled";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,7 +76,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
@Nullable
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
if (this.hasWaterlogging()) {
|
||||
FluidState state = context.getLevel().getFluidState(context.getClickedPos());
|
||||
var state = context.getLevel().getFluidState(context.getClickedPos());
|
||||
return this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, state.is(FluidTags.WATER) && state.getAmount() == 8);
|
||||
}
|
||||
return super.getStateForPlacement(context);
|
||||
|
@ -100,11 +100,11 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> drops = super.getDrops(state, builder);
|
||||
var drops = super.getDrops(state, builder);
|
||||
|
||||
BlockEntity tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
|
||||
var tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
|
||||
if (tile instanceof BlockEntityImpl) {
|
||||
for (ItemStack stack : drops) {
|
||||
for (var stack : drops) {
|
||||
if (stack.getItem() != this.asItem())
|
||||
continue;
|
||||
((BlockEntityImpl) tile).modifyDrop(stack);
|
||||
|
@ -117,7 +117,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
@Override
|
||||
public void onPlace(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityImpl)
|
||||
((BlockEntityImpl) tile).dropInventory();
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
|
||||
@Override
|
||||
public void setPlacedBy(Level levelIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityImpl)
|
||||
((BlockEntityImpl) tile).loadDataOnPlace(stack);
|
||||
}
|
||||
|
@ -144,9 +144,9 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
|
||||
private void updateRedstoneState(Level level, BlockPos pos) {
|
||||
if (!level.isClientSide) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityImpl impl) {
|
||||
int newPower = level.getBestNeighborSignal(pos);
|
||||
var newPower = level.getBestNeighborSignal(pos);
|
||||
if (impl.redstonePower != newPower)
|
||||
level.scheduleTick(pos, this, 4);
|
||||
}
|
||||
|
@ -156,9 +156,9 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
@Override
|
||||
public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
|
||||
if (!levelIn.isClientSide) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityImpl impl) {
|
||||
int newPower = levelIn.getBestNeighborSignal(pos);
|
||||
var newPower = levelIn.getBestNeighborSignal(pos);
|
||||
if (impl.redstonePower != newPower)
|
||||
impl.onRedstonePowerChange(newPower);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,13 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -18,13 +17,13 @@ import java.util.function.Supplier;
|
|||
public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState, ICustomRenderType {
|
||||
|
||||
public BlockDecayedLeaves() {
|
||||
super("decayed_leaves", Properties.create(Material.LEAVES).hardnessAndResistance(0.2F).sound(SoundType.PLANT).notSolid().tickRandomly());
|
||||
super("decayed_leaves", Properties.of(Material.LEAVES).strength(0.2F).sound(SoundType.GRASS).noOcclusion().randomTicks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) {
|
||||
if (!level.isClientSide) {
|
||||
level.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,13 +32,8 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState,
|
|||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader levelIn, BlockPos pos) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutoutMipped;
|
||||
return RenderType::cutoutMipped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,26 +4,30 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEndFlower;
|
|||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||
import de.ellpeck.naturesaura.reg.*;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.LootParameters;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.ILevelReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.gen.Heightmap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.BushBlock;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
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.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
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.VoxelShape;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -32,52 +36,46 @@ import javax.annotation.Nullable;
|
|||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType {
|
||||
public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType, EntityBlock {
|
||||
|
||||
protected static final VoxelShape SHAPE = Block.makeCuboidShape(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D);
|
||||
protected static final VoxelShape SHAPE = box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D);
|
||||
|
||||
public BlockEndFlower() {
|
||||
super(Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0.5F).sound(SoundType.PLANT));
|
||||
super(Properties.of(Material.GRASS).noCollission().strength(0.5F).sound(SoundType.GRASS));
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
ModRegistry.add(this);
|
||||
ModRegistry.add(new ModTileType<>(BlockEntityEndFlower::new, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d vec3d = state.getOffset(levelIn, pos);
|
||||
return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z);
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
var vec3d = state.getOffset(levelIn, pos);
|
||||
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDragonTick(LivingUpdateEvent event) {
|
||||
LivingEntity living = event.getEntityLiving();
|
||||
if (living.level.isClientSide || !(living instanceof EnderDragonEntity))
|
||||
var living = event.getEntityLiving();
|
||||
if (living.level.isClientSide || !(living instanceof EnderDragon dragon))
|
||||
return;
|
||||
EnderDragonEntity dragon = (EnderDragonEntity) living;
|
||||
if (dragon.deathTicks < 150 || dragon.deathTicks % 10 != 0)
|
||||
if (dragon.deathTime < 150 || dragon.deathTime % 10 != 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int x = dragon.level.rand.nextInt(256) - 128;
|
||||
int z = dragon.level.rand.nextInt(256) - 128;
|
||||
BlockPos pos = new BlockPos(x, dragon.level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z);
|
||||
if (!dragon.level.isBlockLoaded(pos))
|
||||
for (var i = 0; i < 6; i++) {
|
||||
var x = dragon.level.random.nextInt(256) - 128;
|
||||
var z = dragon.level.random.nextInt(256) - 128;
|
||||
var pos = new BlockPos(x, dragon.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z);
|
||||
if (!dragon.level.isLoaded(pos))
|
||||
continue;
|
||||
if (dragon.level.getBlockState(pos.down()).getBlock() != Blocks.END_STONE)
|
||||
if (dragon.level.getBlockState(pos.below()).getBlock() != Blocks.END_STONE)
|
||||
continue;
|
||||
dragon.level.setBlockState(pos, this.getDefaultState());
|
||||
dragon.level.setBlockAndUpdate(pos, this.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidGround(BlockState state, IBlockReader levelIn, BlockPos pos) {
|
||||
return state.getBlock() == Blocks.END_STONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) {
|
||||
return levelIn.getBlockState(pos.down()).getBlock() == Blocks.END_STONE;
|
||||
public boolean canSurvive(BlockState state, LevelReader levelIn, BlockPos pos) {
|
||||
return levelIn.getBlockState(pos.below()).getBlock() == Blocks.END_STONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,29 +85,24 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockState state, IBlockReader level) {
|
||||
return new BlockEntityEndFlower();
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockEntityEndFlower(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBlockEntity(BlockState state) {
|
||||
return true;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
|
||||
return willHarvest || super.removedByPlayer(state, level, pos, player, willHarvest, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) {
|
||||
super.harvestBlock(levelIn, player, pos, state, te, stack);
|
||||
levelIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
public void playerDestroy(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) {
|
||||
super.playerDestroy(levelIn, player, pos, state, te, stack);
|
||||
levelIn.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
BlockEntity tile = builder.get(LootParameters.BLOCK_ENTITY);
|
||||
var tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
|
||||
if (tile instanceof BlockEntityEndFlower && ((BlockEntityEndFlower) tile).isDrainMode)
|
||||
return NonNullList.create();
|
||||
return super.getDrops(state, builder);
|
||||
|
@ -127,6 +120,6 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
|
|||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutout;
|
||||
return RenderType::cutout;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,13 @@ import de.ellpeck.naturesaura.items.ModItems;
|
|||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -28,8 +26,6 @@ import net.minecraft.world.item.TooltipFlag;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -43,8 +39,6 @@ import net.minecraftforge.network.NetworkHooks;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState {
|
||||
|
||||
|
@ -62,7 +56,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void addEnderNameInfo(ItemStack stack, List<Component> tooltip) {
|
||||
String name = getEnderName(stack);
|
||||
var name = getEnderName(stack);
|
||||
if (name != null && !name.isEmpty()) {
|
||||
tooltip.add(new TextComponent(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name", ChatFormatting.ITALIC + name + ChatFormatting.RESET)));
|
||||
} else {
|
||||
|
@ -75,18 +69,18 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
var player = event.getPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
ItemStack stack = event.getLeft();
|
||||
var stack = event.getLeft();
|
||||
if (stack.getItem() != this.asItem() && stack.getItem() != ModItems.ENDER_ACCESS)
|
||||
return;
|
||||
ItemStack second = event.getRight();
|
||||
var second = event.getRight();
|
||||
if (second.getItem() != Items.ENDER_EYE || second.getCount() < stack.getCount())
|
||||
return;
|
||||
String name = event.getName();
|
||||
var name = event.getName();
|
||||
if (name == null || name.isEmpty())
|
||||
return;
|
||||
if (ILevelData.getOverworldData(player.level).isEnderStorageLocked(name))
|
||||
return;
|
||||
ItemStack output = stack.copy();
|
||||
var output = stack.copy();
|
||||
output.getOrCreateTag().putString(NaturesAura.MOD_ID + ":ender_name", name);
|
||||
event.setOutput(output);
|
||||
event.setMaterialCost(stack.getCount());
|
||||
|
@ -96,7 +90,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
@Override
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!levelIn.isClientSide) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityEnderCrate crate && crate.canOpen()) {
|
||||
crate.drainAura(2500);
|
||||
NetworkHooks.openGui((ServerPlayer) player, crate, pos);
|
||||
|
@ -114,24 +108,19 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
int j = rand.nextInt(2) * 2 - 1;
|
||||
int k = rand.nextInt(2) * 2 - 1;
|
||||
double d0 = (double) pos.getX() + 0.5D + 0.25D * (double) j;
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var j = rand.nextInt(2) * 2 - 1;
|
||||
var k = rand.nextInt(2) * 2 - 1;
|
||||
var d0 = (double) pos.getX() + 0.5D + 0.25D * (double) j;
|
||||
double d1 = (float) pos.getY() + rand.nextFloat();
|
||||
double d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k;
|
||||
var d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k;
|
||||
double d3 = rand.nextFloat() * (float) j;
|
||||
double d4 = ((double) rand.nextFloat() - 0.5D) * 0.125D;
|
||||
var d4 = ((double) rand.nextFloat() - 0.5D) * 0.125D;
|
||||
double d5 = rand.nextFloat() * (float) k;
|
||||
levelIn.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tuple<BlockEntityType<BlockEntityEnderCrate>, Supplier<Function<? super BlockEntityRenderDispatcher, ? extends BlockEntityRenderer<? super BlockEntityEnderCrate>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.ENDER_CRATE, () -> RenderEnderCrate::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||
|
@ -139,4 +128,9 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.ENDER_CRATE, RenderEnderCrate::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,19 +6,19 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFieldCreator;
|
|||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.InteractionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
@ -26,44 +26,44 @@ import java.util.Random;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockFieldCreator extends BlockContainerImpl implements ICustomBlockState, ICustomRenderType {
|
||||
|
||||
public BlockFieldCreator() {
|
||||
super("field_creator", BlockEntityFieldCreator::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).notSolid().sound(SoundType.STONE));
|
||||
super("field_creator", BlockEntityFieldCreator::new, Properties.of(Material.STONE).strength(2F).noCollission().sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult p_225533_6_) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult p_225533_6_) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFieldCreator) {
|
||||
if (!levelIn.isClientSide) {
|
||||
String key = NaturesAura.MOD_ID + ":field_creator_pos";
|
||||
CompoundTag compound = player.getPersistentData();
|
||||
if (!player.isSneaking() && compound.contains(key)) {
|
||||
BlockPos stored = BlockPos.fromLong(compound.getLong(key));
|
||||
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile;
|
||||
var key = NaturesAura.MOD_ID + ":field_creator_pos";
|
||||
var compound = player.getPersistentData();
|
||||
if (!player.isCrouching() && compound.contains(key)) {
|
||||
var stored = BlockPos.of(compound.getLong(key));
|
||||
var creator = (BlockEntityFieldCreator) tile;
|
||||
if (!pos.equals(stored)) {
|
||||
if (creator.isCloseEnough(stored)) {
|
||||
BlockEntity otherTile = levelIn.getBlockEntity(stored);
|
||||
if (otherTile instanceof BlockEntityFieldCreator) {
|
||||
var otherTile = levelIn.getBlockEntity(stored);
|
||||
if (otherTile instanceof BlockEntityFieldCreator otherCreator) {
|
||||
creator.connectionOffset = stored.subtract(pos);
|
||||
creator.isMain = true;
|
||||
creator.sendToClients();
|
||||
|
||||
BlockEntityFieldCreator otherCreator = (BlockEntityFieldCreator) otherTile;
|
||||
otherCreator.connectionOffset = pos.subtract(stored);
|
||||
otherCreator.isMain = false;
|
||||
otherCreator.sendToClients();
|
||||
|
||||
compound.remove(key);
|
||||
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".connected"), true);
|
||||
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".connected"), true);
|
||||
} else
|
||||
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".stored_pos_gone"), true);
|
||||
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".stored_pos_gone"), true);
|
||||
} else
|
||||
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".too_far"), true);
|
||||
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".too_far"), true);
|
||||
} else
|
||||
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".same_position"), true);
|
||||
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".same_position"), true);
|
||||
} else {
|
||||
compound.putLong(key, pos.toLong());
|
||||
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".stored_pos"), true);
|
||||
compound.putLong(key, pos.asLong());
|
||||
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".stored_pos"), true);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@ -74,11 +74,9 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFieldCreator) {
|
||||
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile;
|
||||
if (creator.isCharged) {
|
||||
BlockPos connected = creator.getConnectedPos();
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFieldCreator creator && creator.isCharged) {
|
||||
var connected = creator.getConnectedPos();
|
||||
if (connected != null)
|
||||
NaturesAuraAPI.instance().spawnParticleStream(
|
||||
pos.getX() + 0.25F + rand.nextFloat() * 0.5F,
|
||||
|
@ -91,7 +89,6 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
|
@ -100,6 +97,6 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
|||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutoutMipped;
|
||||
return RenderType::cutoutMipped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,23 +4,24 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFireworkGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockFireworkGenerator() {
|
||||
super("firework_generator", BlockEntityFireworkGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
|
||||
super("firework_generator", BlockEntityFireworkGenerator::new, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(4);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,24 +4,24 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFlowerGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockFlowerGenerator() {
|
||||
super("flower_generator", BlockEntityFlowerGenerator::new, Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F));
|
||||
super("flower_generator", BlockEntityFlowerGenerator::new, Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(3, 1, 3);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(3, 1, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,13 +2,14 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.FlowerPotBlock;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.FlowerPotBlock;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockFlowerPot extends FlowerPotBlock implements ICustomBlockState, IModItem, INoItemBlock, ICustomRenderType {
|
||||
|
||||
public BlockFlowerPot(Supplier<FlowerPotBlock> emptyPot, Supplier<? extends Block> block, Properties props) {
|
||||
super(emptyPot, block, props);
|
||||
ModRegistry.add(this);
|
||||
|
@ -18,16 +19,16 @@ public class BlockFlowerPot extends FlowerPotBlock implements ICustomBlockState,
|
|||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models()
|
||||
.withExistingParent(this.getBaseName(), "block/flower_pot_cross")
|
||||
.texture("plant", "block/" + this.getFlower().getRegistryName().getPath()));
|
||||
.texture("plant", "block/" + this.getContent().getRegistryName().getPath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return "potted_" + this.getFlower().getRegistryName().getPath();
|
||||
return "potted_" + this.getContent().getRegistryName().getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutout;
|
||||
return RenderType::cutout;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,41 +4,41 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFurnaceHeater;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
|
||||
private static final VoxelShape[] SHAPES = new VoxelShape[]{
|
||||
Block.makeCuboidShape(2, 12, 2, 14, 16, 14), // Down
|
||||
Block.makeCuboidShape(2, 0, 2, 14, 4, 14), // Up
|
||||
Block.makeCuboidShape(2, 2, 12, 14, 14, 16), // North
|
||||
Block.makeCuboidShape(2, 2, 0, 14, 14, 4), // South
|
||||
Block.makeCuboidShape(12, 2, 2, 16, 14, 14), // West
|
||||
Block.makeCuboidShape(0, 2, 2, 4, 14, 14) // East
|
||||
box(2, 12, 2, 14, 16, 14), // Down
|
||||
box(2, 0, 2, 14, 4, 14), // Up
|
||||
box(2, 2, 12, 14, 14, 16), // North
|
||||
box(2, 2, 0, 14, 14, 4), // South
|
||||
box(12, 2, 2, 16, 14, 14), // West
|
||||
box(0, 2, 2, 4, 14, 14) // East
|
||||
};
|
||||
|
||||
public BlockFurnaceHeater() {
|
||||
super("furnace_heater", BlockEntityFurnaceHeater::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
|
||||
super("furnace_heater", BlockEntityFurnaceHeater::new, Properties.of(Material.STONE).strength(3F));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,9 +49,9 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFurnaceHeater && ((BlockEntityFurnaceHeater) tile).isActive) {
|
||||
Direction facing = stateIn.get(FACING);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFurnaceHeater heater && heater.isActive) {
|
||||
var facing = stateIn.getValue(FACING);
|
||||
|
||||
float x;
|
||||
float y;
|
||||
|
@ -65,35 +65,35 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
|
|||
y = 1F;
|
||||
z = 0.35F + rand.nextFloat() * 0.3F;
|
||||
} else {
|
||||
x = facing.getZOffset() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getXOffset() < 0 ? 1 : 0;
|
||||
x = facing.getStepZ() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getStepX() < 0 ? 1 : 0;
|
||||
y = 0.35F + rand.nextFloat() * 0.3F;
|
||||
z = facing.getXOffset() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getZOffset() < 0 ? 1 : 0;
|
||||
z = facing.getStepX() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getStepZ() < 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
pos.getX() + x, pos.getY() + y, pos.getZ() + z,
|
||||
(rand.nextFloat() * 0.016F + 0.01F) * facing.getXOffset(),
|
||||
(rand.nextFloat() * 0.016F + 0.01F) * facing.getYOffset(),
|
||||
(rand.nextFloat() * 0.016F + 0.01F) * facing.getZOffset(),
|
||||
(rand.nextFloat() * 0.016F + 0.01F) * facing.getStepX(),
|
||||
(rand.nextFloat() * 0.016F + 0.01F) * facing.getStepY(),
|
||||
(rand.nextFloat() * 0.016F + 0.01F) * facing.getStepZ(),
|
||||
0xf46e42, rand.nextFloat() + 0.5F, 55, 0F, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPES[state.get(FACING).getIndex()];
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPES[state.getValue(FACING).ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return super.getStateForPlacement(context).with(FACING, context.getFace());
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return super.getStateForPlacement(context).setValue(FACING, context.getClickedFace());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,30 +1,19 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.BlockEntityType;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<BlockEntityGeneratorLimitRemover>, ICustomBlockState {
|
||||
|
||||
public BlockGeneratorLimitRemover() {
|
||||
super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tuple<BlockEntityType<BlockEntityGeneratorLimitRemover>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityGeneratorLimitRemover>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.GENERATOR_LIMIT_REMOVER, () -> RenderGeneratorLimitRemover::new);
|
||||
super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,4 +23,9 @@ public class BlockGeneratorLimitRemover extends BlockContainerImpl implements IT
|
|||
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.GENERATOR_LIMIT_REMOVER, RenderGeneratorLimitRemover::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,104 +6,104 @@ import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
|
|||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.RedstoneWireBlock;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.properties.RedstoneSide;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.ILevel;
|
||||
import net.minecraft.level.ILevelReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.RedStoneWireBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.block.state.properties.RedstoneSide;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, ICustomBlockState, ICustomItemModel, ICustomRenderType {
|
||||
|
||||
public static final EnumProperty<RedstoneSide> NORTH = BlockStateProperties.REDSTONE_NORTH;
|
||||
public static final EnumProperty<RedstoneSide> EAST = BlockStateProperties.REDSTONE_EAST;
|
||||
public static final EnumProperty<RedstoneSide> SOUTH = BlockStateProperties.REDSTONE_SOUTH;
|
||||
public static final EnumProperty<RedstoneSide> WEST = BlockStateProperties.REDSTONE_WEST;
|
||||
protected static final VoxelShape[] SHAPES = new VoxelShape[]{Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
|
||||
public static final EnumProperty<RedstoneSide> NORTH = BlockStateProperties.NORTH_REDSTONE;
|
||||
public static final EnumProperty<RedstoneSide> EAST = BlockStateProperties.EAST_REDSTONE;
|
||||
public static final EnumProperty<RedstoneSide> SOUTH = BlockStateProperties.SOUTH_REDSTONE;
|
||||
public static final EnumProperty<RedstoneSide> WEST = BlockStateProperties.WEST_REDSTONE;
|
||||
protected static final VoxelShape[] SHAPES = new VoxelShape[]{box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
|
||||
|
||||
public BlockGoldPowder() {
|
||||
super("gold_powder", Properties.from(Blocks.REDSTONE_WIRE));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(NORTH, RedstoneSide.NONE).with(EAST, RedstoneSide.NONE).with(SOUTH, RedstoneSide.NONE).with(WEST, RedstoneSide.NONE));
|
||||
super("gold_powder", Properties.copy(Blocks.REDSTONE_WIRE));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(NORTH, RedstoneSide.NONE).setValue(EAST, RedstoneSide.NONE).setValue(SOUTH, RedstoneSide.NONE).setValue(WEST, RedstoneSide.NONE));
|
||||
}
|
||||
|
||||
private static int getShapeIndex(BlockState state) {
|
||||
int i = 0;
|
||||
boolean n = state.get(NORTH) != RedstoneSide.NONE;
|
||||
boolean e = state.get(EAST) != RedstoneSide.NONE;
|
||||
boolean s = state.get(SOUTH) != RedstoneSide.NONE;
|
||||
boolean w = state.get(WEST) != RedstoneSide.NONE;
|
||||
var i = 0;
|
||||
var n = state.getValue(NORTH) != RedstoneSide.NONE;
|
||||
var e = state.getValue(EAST) != RedstoneSide.NONE;
|
||||
var s = state.getValue(SOUTH) != RedstoneSide.NONE;
|
||||
var w = state.getValue(WEST) != RedstoneSide.NONE;
|
||||
|
||||
if (n || s && !n && !e && !w) {
|
||||
i |= 1 << Direction.NORTH.getHorizontalIndex();
|
||||
i |= 1 << Direction.NORTH.ordinal();
|
||||
}
|
||||
if (e || w && !n && !e && !s) {
|
||||
i |= 1 << Direction.EAST.getHorizontalIndex();
|
||||
i |= 1 << Direction.EAST.ordinal();
|
||||
}
|
||||
if (s || n && !e && !s && !w) {
|
||||
i |= 1 << Direction.SOUTH.getHorizontalIndex();
|
||||
i |= 1 << Direction.SOUTH.ordinal();
|
||||
}
|
||||
if (w || e && !n && !s && !w) {
|
||||
i |= 1 << Direction.WEST.getHorizontalIndex();
|
||||
i |= 1 << Direction.WEST.ordinal();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(NORTH, EAST, SOUTH, WEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockColor getBlockColor() {
|
||||
public BlockColor getBlockColor() {
|
||||
return (state, levelIn, pos, tintIndex) -> 0xf4cb42;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPES[getShapeIndex(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
IBlockReader iblockreader = context.getLevel();
|
||||
BlockPos blockpos = context.getPos();
|
||||
return this.getDefaultState().with(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).with(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).with(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).with(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH));
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockGetter iblockreader = context.getLevel();
|
||||
var blockpos = context.getClickedPos();
|
||||
return this.defaultBlockState().setValue(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).setValue(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).setValue(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).setValue(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, ILevel levelIn, BlockPos currentPos, BlockPos facingPos) {
|
||||
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor levelIn, BlockPos currentPos, BlockPos facingPos) {
|
||||
if (facing == Direction.DOWN) {
|
||||
return stateIn;
|
||||
} else {
|
||||
return facing == Direction.UP ? stateIn.with(WEST, this.getSide(levelIn, currentPos, Direction.WEST)).with(EAST, this.getSide(levelIn, currentPos, Direction.EAST)).with(NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).with(SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.with(RedstoneWireBlock.FACING_PROPERTY_MAP.get(facing), this.getSide(levelIn, currentPos, facing));
|
||||
return facing == Direction.UP ? stateIn.setValue(WEST, this.getSide(levelIn, currentPos, Direction.WEST)).setValue(EAST, this.getSide(levelIn, currentPos, Direction.EAST)).setValue(NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).setValue(SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.setValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(facing), this.getSide(levelIn, currentPos, facing));
|
||||
}
|
||||
}
|
||||
|
||||
private RedstoneSide getSide(IBlockReader levelIn, BlockPos pos, Direction face) {
|
||||
BlockPos blockpos = pos.offset(face);
|
||||
BlockState blockstate = levelIn.getBlockState(blockpos);
|
||||
BlockPos blockpos1 = pos.up();
|
||||
BlockState blockstate1 = levelIn.getBlockState(blockpos1);
|
||||
if (!blockstate1.isNormalCube(levelIn, blockpos1)) {
|
||||
boolean flag = blockstate.isSolidSide(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
if (flag && this.canConnectTo(levelIn.getBlockState(blockpos.up()))) {
|
||||
if (blockstate.hasOpaqueCollisionShape(levelIn, blockpos)) {
|
||||
private RedstoneSide getSide(BlockGetter levelIn, BlockPos pos, Direction face) {
|
||||
var blockpos = pos.relative(face);
|
||||
var blockstate = levelIn.getBlockState(blockpos);
|
||||
var blockpos1 = pos.above();
|
||||
var blockstate1 = levelIn.getBlockState(blockpos1);
|
||||
if (!blockstate1.isCollisionShapeFullBlock(levelIn, blockpos1)) {
|
||||
var flag = blockstate.isFaceSturdy(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
if (flag && this.canConnectTo(levelIn.getBlockState(blockpos.above()))) {
|
||||
if (blockstate.isCollisionShapeFullBlock(levelIn, blockpos)) {
|
||||
return RedstoneSide.UP;
|
||||
}
|
||||
|
||||
|
@ -111,41 +111,41 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
}
|
||||
}
|
||||
|
||||
return !this.canConnectTo(blockstate) && (blockstate.isNormalCube(levelIn, blockpos) || !this.canConnectTo(levelIn.getBlockState(blockpos.down()))) ? RedstoneSide.NONE : RedstoneSide.SIDE;
|
||||
return !this.canConnectTo(blockstate) && (blockstate.isCollisionShapeFullBlock(levelIn, blockpos) || !this.canConnectTo(levelIn.getBlockState(blockpos.below()))) ? RedstoneSide.NONE : RedstoneSide.SIDE;
|
||||
}
|
||||
|
||||
protected boolean canConnectTo(BlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
var block = blockState.getBlock();
|
||||
return block == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) {
|
||||
BlockPos blockpos = pos.down();
|
||||
BlockState blockstate = levelIn.getBlockState(blockpos);
|
||||
return blockstate.isSolidSide(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
public boolean canSurvive(BlockState state, LevelReader levelIn, BlockPos pos) {
|
||||
var blockpos = pos.below();
|
||||
var blockstate = levelIn.getBlockState(blockpos);
|
||||
return blockstate.isFaceSturdy(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return Shapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState state, Level levelIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
public void onPlace(BlockState state, Level levelIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
if (oldState.getBlock() != state.getBlock() && !levelIn.isClientSide) {
|
||||
for (Direction direction : Direction.Plane.VERTICAL) {
|
||||
levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
|
||||
for (var direction : Direction.Plane.VERTICAL) {
|
||||
levelIn.updateNeighborsAt(pos.relative(direction), this);
|
||||
}
|
||||
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, pos.offset(direction1));
|
||||
for (var direction1 : Direction.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, pos.relative(direction1));
|
||||
}
|
||||
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos = pos.offset(direction2);
|
||||
if (levelIn.getBlockState(blockpos).isNormalCube(levelIn, blockpos)) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.up());
|
||||
for (var direction2 : Direction.Plane.HORIZONTAL) {
|
||||
var blockpos = pos.relative(direction2);
|
||||
if (levelIn.getBlockState(blockpos).isCollisionShapeFullBlock(levelIn, blockpos)) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.above());
|
||||
} else {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.down());
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.below());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,22 +153,22 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!isMoving && state.getBlock() != newState.getBlock()) {
|
||||
super.onReplaced(state, levelIn, pos, newState, isMoving);
|
||||
super.onRemove(state, levelIn, pos, newState, isMoving);
|
||||
if (!levelIn.isClientSide) {
|
||||
for (Direction direction : Direction.values()) {
|
||||
levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
|
||||
for (var direction : Direction.values()) {
|
||||
levelIn.updateNeighborsAt(pos.relative(direction), this);
|
||||
}
|
||||
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, pos.offset(direction1));
|
||||
for (var direction1 : Direction.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, pos.relative(direction1));
|
||||
}
|
||||
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos = pos.offset(direction2);
|
||||
if (levelIn.getBlockState(blockpos).isNormalCube(levelIn, blockpos)) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.up());
|
||||
for (var direction2 : Direction.Plane.HORIZONTAL) {
|
||||
var blockpos = pos.relative(direction2);
|
||||
if (levelIn.getBlockState(blockpos).isCollisionShapeFullBlock(levelIn, blockpos)) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.above());
|
||||
} else {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.down());
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.below());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,33 +179,33 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
@Override
|
||||
public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
if (!levelIn.isClientSide) {
|
||||
if (!state.isValidPosition(levelIn, pos)) {
|
||||
spawnDrops(state, levelIn, pos);
|
||||
if (!state.canSurvive(levelIn, pos)) {
|
||||
dropResources(state, levelIn, pos);
|
||||
levelIn.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiagonalNeighbors(BlockState state, ILevel levelIn, BlockPos pos, int flags, int recursionLeft) {
|
||||
BlockPos.Mutable pool = new BlockPos.Mutable();
|
||||
for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||
RedstoneSide redstoneside = state.get(RedstoneWireBlock.FACING_PROPERTY_MAP.get(direction));
|
||||
if (redstoneside != RedstoneSide.NONE && levelIn.getBlockState(pool.setPos(pos).move(direction)).getBlock() != this) {
|
||||
public void updateIndirectNeighbourShapes(BlockState state, LevelAccessor levelIn, BlockPos pos, int flags, int recursionLeft) {
|
||||
var pool = new BlockPos.MutableBlockPos();
|
||||
for (var direction : Direction.Plane.HORIZONTAL) {
|
||||
var redstoneside = state.getValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(direction));
|
||||
if (redstoneside != RedstoneSide.NONE && levelIn.getBlockState(pool.set(pos).move(direction)).getBlock() != this) {
|
||||
pool.move(Direction.DOWN);
|
||||
BlockState blockstate = levelIn.getBlockState(pool);
|
||||
var blockstate = levelIn.getBlockState(pool);
|
||||
if (blockstate.getBlock() != Blocks.OBSERVER) {
|
||||
BlockPos blockpos = pool.offset(direction.getOpposite());
|
||||
BlockState blockstate1 = blockstate.updatePostPlacement(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos);
|
||||
replaceBlock(blockstate, blockstate1, levelIn, pool, flags);
|
||||
var blockpos = pool.relative(direction.getOpposite());
|
||||
var blockstate1 = blockstate.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos);
|
||||
updateOrDestroy(blockstate, blockstate1, levelIn, pool, flags);
|
||||
}
|
||||
|
||||
pool.setPos(pos).move(direction).move(Direction.UP);
|
||||
BlockState blockstate3 = levelIn.getBlockState(pool);
|
||||
pool.set(pos).move(direction).move(Direction.UP);
|
||||
var blockstate3 = levelIn.getBlockState(pool);
|
||||
if (blockstate3.getBlock() != Blocks.OBSERVER) {
|
||||
BlockPos blockpos1 = pool.offset(direction.getOpposite());
|
||||
BlockState blockstate2 = blockstate3.updatePostPlacement(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1);
|
||||
replaceBlock(blockstate3, blockstate2, levelIn, pool, flags);
|
||||
var blockpos1 = pool.relative(direction.getOpposite());
|
||||
var blockstate2 = blockstate3.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1);
|
||||
updateOrDestroy(blockstate3, blockstate2, levelIn, pool, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -214,10 +214,10 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
|
||||
private void notifyWireNeighborsOfStateChange(Level levelIn, BlockPos pos) {
|
||||
if (levelIn.getBlockState(pos).getBlock() == this) {
|
||||
levelIn.notifyNeighborsOfStateChange(pos, this);
|
||||
levelIn.updateNeighborsAt(pos, this);
|
||||
|
||||
for (Direction direction : Direction.values()) {
|
||||
levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
|
||||
for (var direction : Direction.values()) {
|
||||
levelIn.updateNeighborsAt(pos.relative(direction), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,6 +234,6 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutoutMipped;
|
||||
return RenderType::cutoutMipped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,21 +4,21 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.material.MaterialColor;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.state.IntegerProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.biome.BiomeColors;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
@ -30,17 +30,17 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, HIGHEST_STAGE);
|
||||
|
||||
public BlockGoldenLeaves() {
|
||||
super(Properties.create(Material.LEAVES, MaterialColor.GOLD).hardnessAndResistance(0.2F).tickRandomly().notSolid().sound(SoundType.PLANT));
|
||||
super(Properties.of(Material.LEAVES, MaterialColor.GOLD).strength(0.2F).randomTicks().noCollission().sound(SoundType.GRASS));
|
||||
ModRegistry.add(this);
|
||||
}
|
||||
|
||||
public static boolean convert(Level level, BlockPos pos) {
|
||||
BlockState state = level.getBlockState(pos);
|
||||
var state = level.getBlockState(pos);
|
||||
if (state.getBlock() instanceof LeavesBlock && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
|
||||
if (!level.isClientSide) {
|
||||
level.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState()
|
||||
.with(DISTANCE, state.hasProperty(DISTANCE) ? state.get(DISTANCE) : 1)
|
||||
.with(PERSISTENT, state.hasProperty(PERSISTENT) ? state.get(PERSISTENT) : false));
|
||||
level.setBlockAndUpdate(pos, ModBlocks.GOLDEN_LEAVES.defaultBlockState()
|
||||
.setValue(DISTANCE, state.hasProperty(DISTANCE) ? state.getValue(DISTANCE) : 1)
|
||||
.setValue(PERSISTENT, state.hasProperty(PERSISTENT) ? state.getValue(PERSISTENT) : false));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
if (stateIn.get(STAGE) == HIGHEST_STAGE && rand.nextFloat() >= 0.75F)
|
||||
if (stateIn.getValue(STAGE) == HIGHEST_STAGE && rand.nextFloat() >= 0.75F)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
pos.getX() + rand.nextFloat(),
|
||||
pos.getY() + rand.nextFloat(),
|
||||
|
@ -65,19 +65,19 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(STAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IBlockColor getBlockColor() {
|
||||
public BlockColor getBlockColor() {
|
||||
return (state, levelIn, pos, tintIndex) -> {
|
||||
int color = 0xF2FF00;
|
||||
var color = 0xF2FF00;
|
||||
if (state != null && levelIn != null && pos != null) {
|
||||
int foliage = BiomeColors.getFoliageColor(levelIn, pos);
|
||||
return Helper.blendColors(color, foliage, state.get(STAGE) / (float) HIGHEST_STAGE);
|
||||
var foliage = BiomeColors.getAverageFoliageColor(levelIn, pos);
|
||||
return Helper.blendColors(color, foliage, state.getValue(STAGE) / (float) HIGHEST_STAGE);
|
||||
} else {
|
||||
return color;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IItemColor getItemColor() {
|
||||
public ItemColor getItemColor() {
|
||||
return (stack, tintIndex) -> 0xF2FF00;
|
||||
}
|
||||
|
||||
|
@ -94,21 +94,21 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
|
||||
super.randomTick(state, levelIn, pos, random);
|
||||
if (!levelIn.isClientSide) {
|
||||
int stage = state.get(STAGE);
|
||||
int stage = state.getValue(STAGE);
|
||||
if (stage < HIGHEST_STAGE) {
|
||||
levelIn.setBlockState(pos, state.with(STAGE, stage + 1));
|
||||
levelIn.setBlockAndUpdate(pos, state.setValue(STAGE, stage + 1));
|
||||
}
|
||||
|
||||
if (stage > 1) {
|
||||
BlockPos offset = pos.offset(Direction.func_239631_a_(random));
|
||||
if (levelIn.isBlockLoaded(offset))
|
||||
var offset = pos.relative(Direction.getRandom(random));
|
||||
if (levelIn.isLoaded(offset))
|
||||
convert(levelIn, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ticksRandomly(BlockState state) {
|
||||
public boolean isRandomlyTicking(BlockState p_54449_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,27 +5,31 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.IHopper;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.InteractionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Mth;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HopperBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
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.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.BooleanOp;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -33,23 +37,23 @@ import javax.annotation.Nullable;
|
|||
public class BlockGratedChute extends BlockContainerImpl implements ICustomBlockState, ICustomItemModel {
|
||||
|
||||
public static final DirectionProperty FACING = HopperBlock.FACING;
|
||||
private static final VoxelShape INPUT_SHAPE = Block.makeCuboidShape(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D);
|
||||
private static final VoxelShape MIDDLE_SHAPE = Block.makeCuboidShape(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D);
|
||||
private static final VoxelShape INPUT_SHAPE = box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D);
|
||||
private static final VoxelShape MIDDLE_SHAPE = box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D);
|
||||
private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(MIDDLE_SHAPE, INPUT_SHAPE);
|
||||
private static final VoxelShape COMBINED_SHAPE = Shapes.combineAndSimplify(INPUT_MIDDLE_SHAPE, IHopper.INSIDE_BOWL_SHAPE, IBooleanFunction.ONLY_FIRST);
|
||||
private static final VoxelShape DOWN_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D));
|
||||
private static final VoxelShape EAST_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D));
|
||||
private static final VoxelShape NORTH_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D));
|
||||
private static final VoxelShape SOUTH_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D));
|
||||
private static final VoxelShape WEST_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D));
|
||||
private static final VoxelShape DOWN_RAYTRACE_SHAPE = IHopper.INSIDE_BOWL_SHAPE;
|
||||
private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D));
|
||||
private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D));
|
||||
private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D));
|
||||
private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D));
|
||||
private static final VoxelShape COMBINED_SHAPE = Shapes.join(INPUT_MIDDLE_SHAPE, Hopper.INSIDE, BooleanOp.ONLY_FIRST);
|
||||
private static final VoxelShape DOWN_SHAPE = Shapes.or(COMBINED_SHAPE, box(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D));
|
||||
private static final VoxelShape EAST_SHAPE = Shapes.or(COMBINED_SHAPE, box(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D));
|
||||
private static final VoxelShape NORTH_SHAPE = Shapes.or(COMBINED_SHAPE, box(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D));
|
||||
private static final VoxelShape SOUTH_SHAPE = Shapes.or(COMBINED_SHAPE, box(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D));
|
||||
private static final VoxelShape WEST_SHAPE = Shapes.or(COMBINED_SHAPE, box(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D));
|
||||
private static final VoxelShape DOWN_RAYTRACE_SHAPE = Hopper.INSIDE;
|
||||
private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D));
|
||||
private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D));
|
||||
private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.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() {
|
||||
super("grated_chute", BlockEntityGratedChute::new, Properties.create(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL));
|
||||
super("grated_chute", BlockEntityGratedChute::new, Properties.of(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,50 +62,37 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
switch (state.get(FACING)) {
|
||||
case DOWN:
|
||||
return DOWN_SHAPE;
|
||||
case NORTH:
|
||||
return NORTH_SHAPE;
|
||||
case SOUTH:
|
||||
return SOUTH_SHAPE;
|
||||
case WEST:
|
||||
return WEST_SHAPE;
|
||||
case EAST:
|
||||
return EAST_SHAPE;
|
||||
default:
|
||||
return COMBINED_SHAPE;
|
||||
}
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return switch (state.getValue(FACING)) {
|
||||
case DOWN -> DOWN_SHAPE;
|
||||
case NORTH -> NORTH_SHAPE;
|
||||
case SOUTH -> SOUTH_SHAPE;
|
||||
case WEST -> WEST_SHAPE;
|
||||
case EAST -> EAST_SHAPE;
|
||||
default -> COMBINED_SHAPE;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRaytraceShape(BlockState state, IBlockReader levelIn, BlockPos pos) {
|
||||
switch (state.get(FACING)) {
|
||||
case DOWN:
|
||||
return DOWN_RAYTRACE_SHAPE;
|
||||
case NORTH:
|
||||
return NORTH_RAYTRACE_SHAPE;
|
||||
case SOUTH:
|
||||
return SOUTH_RAYTRACE_SHAPE;
|
||||
case WEST:
|
||||
return WEST_RAYTRACE_SHAPE;
|
||||
case EAST:
|
||||
return EAST_RAYTRACE_SHAPE;
|
||||
default:
|
||||
return IHopper.INSIDE_BOWL_SHAPE;
|
||||
}
|
||||
public VoxelShape getInteractionShape(BlockState state, BlockGetter levelIn, BlockPos pos) {
|
||||
return switch (state.getValue(FACING)) {
|
||||
case DOWN -> DOWN_RAYTRACE_SHAPE;
|
||||
case NORTH -> NORTH_RAYTRACE_SHAPE;
|
||||
case SOUTH -> SOUTH_RAYTRACE_SHAPE;
|
||||
case WEST -> WEST_RAYTRACE_SHAPE;
|
||||
case EAST -> EAST_RAYTRACE_SHAPE;
|
||||
default -> Hopper.INSIDE;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!player.isSneaking())
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!player.isCrouching())
|
||||
return InteractionResult.FAIL;
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
if (!(tile instanceof BlockEntityGratedChute))
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (!(tile instanceof BlockEntityGratedChute chute))
|
||||
return InteractionResult.FAIL;
|
||||
if (!levelIn.isClientSide) {
|
||||
BlockEntityGratedChute chute = (BlockEntityGratedChute) tile;
|
||||
chute.isBlacklist = !chute.isBlacklist;
|
||||
chute.sendToClients();
|
||||
}
|
||||
|
@ -110,29 +101,29 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
Direction newFacing = context.getFace().getOpposite();
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
var newFacing = context.getClickedFace().getOpposite();
|
||||
if (newFacing == Direction.UP)
|
||||
newFacing = Direction.DOWN;
|
||||
return super.getStateForPlacement(context).with(FACING, newFacing);
|
||||
return super.getStateForPlacement(context).setValue(FACING, newFacing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
public boolean hasAnalogOutputSignal(BlockState p_60457_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
public int getAnalogOutputSignal(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityGratedChute) {
|
||||
IItemHandler handler = ((BlockEntityGratedChute) tile).getItemHandler();
|
||||
ItemStack stack = handler.getStackInSlot(0);
|
||||
var stack = handler.getStackInSlot(0);
|
||||
if (stack.isEmpty())
|
||||
return 0;
|
||||
return Mth.ceil(stack.getCount() / (float) stack.getMaxStackSize() * 15);
|
||||
|
@ -141,8 +132,8 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,23 +2,24 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityHopperUpgrade;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable {
|
||||
|
||||
public BlockHopperUpgrade() {
|
||||
super("hopper_upgrade", BlockEntityHopperUpgrade::new, Properties.create(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL));
|
||||
super("hopper_upgrade", BlockEntityHopperUpgrade::new, Properties.of(Material.METAL).strength(2.5F).sound(SoundType.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(7);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(7);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,31 +3,31 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.InteractionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.phys.BlockHitResult;
|
||||
|
||||
public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockItemDistributor() {
|
||||
super("item_distributor", BlockEntityItemDistributor::new, Properties.from(Blocks.STONE_BRICKS));
|
||||
super("item_distributor", BlockEntityItemDistributor::new, Properties.copy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!player.isSneaking())
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!player.isCrouching())
|
||||
return InteractionResult.FAIL;
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (!(tile instanceof BlockEntityItemDistributor))
|
||||
return InteractionResult.FAIL;
|
||||
if (!levelIn.isClientSide) {
|
||||
BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile;
|
||||
var distributor = (BlockEntityItemDistributor) tile;
|
||||
distributor.isRandomMode = !distributor.isRandomMode;
|
||||
distributor.sendToClients();
|
||||
}
|
||||
|
|
|
@ -5,15 +5,15 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import de.ellpeck.naturesaura.reg.INoItemBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
@ -22,16 +22,16 @@ import java.util.function.Supplier;
|
|||
|
||||
public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemBlock, ICustomRenderType {
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12);
|
||||
private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12);
|
||||
|
||||
public BlockLight() {
|
||||
super("light", Properties.create(Material.WOOL).doesNotBlockMovement().setLightLevel(s -> 15));
|
||||
super("light", Properties.of(Material.WOOL).noCollission().lightLevel(s -> 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (var i = 0; i < 2; i++)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F,
|
||||
rand.nextGaussian() * 0.015F, 0, rand.nextGaussian() * 0.015F,
|
||||
|
@ -39,12 +39,12 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,6 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
|
|||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutoutMipped;
|
||||
return RenderType::cutoutMipped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,23 +2,24 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityMossGenerator;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable {
|
||||
|
||||
public BlockMossGenerator() {
|
||||
super("moss_generator", BlockEntityMossGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
||||
super("moss_generator", BlockEntityMossGenerator::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(2);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,32 +9,25 @@ import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
|
|||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.BlockEntityType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider<BlockEntityNatureAltar>, ICustomBlockState {
|
||||
|
||||
|
@ -42,8 +35,8 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
|||
public static final BooleanProperty NETHER = BooleanProperty.create("nether");
|
||||
|
||||
public BlockNatureAltar() {
|
||||
super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.create(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
|
||||
this.setDefaultState(this.getDefaultState().with(NETHER, false));
|
||||
super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.of(Material.STONE).strength(4F));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,30 +51,30 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
|||
|
||||
@Override
|
||||
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tuple<BlockEntityType<BlockEntityNatureAltar>, Supplier<Function<? super BlockEntityRenderDispatcher, ? extends BlockEntityRenderer<? super BlockEntityNatureAltar>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.NATURE_ALTAR, () -> RenderNatureAltar::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
// noop
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(NETHER);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
return super.getStateForPlacement(context).with(NETHER, nether);
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
return super.getStateForPlacement(context).setValue(NETHER, nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.NATURE_ALTAR, RenderNatureAltar::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,29 +2,29 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.BonemealableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IGrowable {
|
||||
public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, BonemealableBlock {
|
||||
|
||||
public BlockNetherGrass() {
|
||||
super("nether_grass", Properties.from(Blocks.NETHERRACK).tickRandomly());
|
||||
super("nether_grass", Properties.copy(Blocks.NETHERRACK).randomTicks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
|
||||
BlockPos up = pos.up();
|
||||
BlockState upState = levelIn.getBlockState(up);
|
||||
if (upState.isSolidSide(levelIn, up, Direction.DOWN))
|
||||
levelIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState());
|
||||
var up = pos.above();
|
||||
var upState = levelIn.getBlockState(up);
|
||||
if (upState.isFaceSturdy(levelIn, up, Direction.DOWN))
|
||||
levelIn.setBlockAndUpdate(pos, Blocks.NETHERRACK.defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,43 +36,43 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canGrow(IBlockReader levelIn, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return levelIn.getBlockState(pos.up()).isAir(levelIn, pos.up());
|
||||
public boolean isValidBonemealTarget(BlockGetter levelIn, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return levelIn.getBlockState(pos.above()).isAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseBonemeal(Level levelIn, Random rand, BlockPos pos, BlockState state) {
|
||||
public boolean isBonemealSuccess(Level levelIn, Random rand, BlockPos pos, BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
|
||||
BlockPos blockpos = pos.up();
|
||||
BlockState blockstate = Blocks.GRASS.getDefaultState();
|
||||
public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
|
||||
var blockpos = pos.above();
|
||||
var blockstate = Blocks.GRASS.defaultBlockState();
|
||||
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
BlockPos blockpos1 = blockpos;
|
||||
int j = 0;
|
||||
for (var i = 0; i < 128; ++i) {
|
||||
var blockpos1 = blockpos;
|
||||
var j = 0;
|
||||
|
||||
while (true) {
|
||||
if (j >= i / 16) {
|
||||
BlockState blockstate2 = level.getBlockState(blockpos1);
|
||||
var blockstate2 = level.getBlockState(blockpos1);
|
||||
if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) {
|
||||
((IGrowable) blockstate.getBlock()).grow(level, rand, blockpos1, blockstate2);
|
||||
((BonemealableBlock) blockstate.getBlock()).performBonemeal(level, rand, blockpos1, blockstate2);
|
||||
}
|
||||
|
||||
if (!blockstate2.isAir()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (blockstate.isValidPosition(level, blockpos1)) {
|
||||
level.setBlockState(blockpos1, blockstate, 3);
|
||||
if (blockstate.canSurvive(level, blockpos1)) {
|
||||
level.setBlock(blockpos1, blockstate, 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
|
||||
if (level.getBlockState(blockpos1.down()).getBlock() != this || level.getBlockState(blockpos1).hasOpaqueCollisionShape(level, blockpos1)) {
|
||||
blockpos1 = blockpos1.offset(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
|
||||
if (level.getBlockState(blockpos1.below()).getBlock() != this || level.getBlockState(blockpos1).isCollisionShapeFullBlock(level, blockpos1)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,17 +7,16 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SaplingBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.ILevel;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SaplingBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.level.SaplingGrowTreeEvent;
|
||||
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -25,22 +24,22 @@ import java.util.Random;
|
|||
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockOakGenerator() {
|
||||
super("oak_generator", BlockEntityOakGenerator::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
|
||||
super("oak_generator", BlockEntityOakGenerator::new, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD));
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
ILevel level = event.getLevel();
|
||||
BlockPos pos = event.getPos();
|
||||
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel(level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
||||
var level = event.getWorld();
|
||||
var pos = event.getPos();
|
||||
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
||||
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
|
||||
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
|
||||
if (!(tile instanceof BlockEntityOakGenerator))
|
||||
return false;
|
||||
|
||||
Random rand = event.getRand();
|
||||
var rand = event.getRand();
|
||||
if (rand.nextInt(10) == 0)
|
||||
((BlockEntityOakGenerator) tile).scheduledBigTrees.add(pos);
|
||||
|
||||
|
@ -59,8 +58,8 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(10);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,39 +1,33 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.tileentity.BlockEntityType;
|
||||
import net.minecraft.util.InteractionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.Level;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider<BlockEntityOfferingTable>, ICustomBlockState {
|
||||
|
||||
private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
|
||||
|
||||
public BlockOfferingTable() {
|
||||
super("offering_table", BlockEntityOfferingTable::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
|
||||
super("offering_table", BlockEntityOfferingTable::new, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,22 +36,22 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tuple<BlockEntityType<BlockEntityOfferingTable>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityOfferingTable>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.OFFERING_TABLE, () -> RenderOfferingTable::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.OFFERING_TABLE, RenderOfferingTable::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
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.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -22,34 +22,34 @@ import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockPickupStopper() {
|
||||
super("pickup_stopper", BlockEntityPickupStopper::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
||||
super("pickup_stopper", BlockEntityPickupStopper::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPickup(EntityItemPickupEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null && !player.isSneaking()) {
|
||||
ItemEntity item = event.getItem();
|
||||
BlockPos pos = item.getPosition();
|
||||
var player = event.getPlayer();
|
||||
if (player != null && !player.isCrouching()) {
|
||||
var item = event.getItem();
|
||||
var pos = item.blockPosition();
|
||||
Helper.getBlockEntitiesInArea(item.level, pos, 8, tile -> {
|
||||
if (!(tile instanceof BlockEntityPickupStopper))
|
||||
if (!(tile instanceof BlockEntityPickupStopper stopper))
|
||||
return false;
|
||||
BlockEntityPickupStopper stopper = (BlockEntityPickupStopper) tile;
|
||||
float radius = stopper.getRadius();
|
||||
var radius = stopper.getRadius();
|
||||
if (radius <= 0F)
|
||||
return false;
|
||||
BlockPos stopperPos = stopper.getPos();
|
||||
if (!new AxisAlignedBB(stopperPos).grow(radius).intersects(item.getBoundingBox()))
|
||||
var stopperPos = stopper.getBlockPos();
|
||||
if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
|
||||
return false;
|
||||
|
||||
event.setCanceled(true);
|
||||
|
||||
if (item.level.getGameTime() % 3 == 0)
|
||||
PacketHandler.sendToAllAround(item.level, pos, 32,
|
||||
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.PICKUP_STOPPER));
|
||||
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.PICKUP_STOPPER));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -57,12 +57,12 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityPickupStopper) {
|
||||
double radius = ((BlockEntityPickupStopper) tile).getRadius();
|
||||
if (radius > 0)
|
||||
return new AxisAlignedBB(pos).grow(radius);
|
||||
return new AABB(pos).inflate(radius);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -4,24 +4,24 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPlacer;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockPlacer() {
|
||||
super("placer", BlockEntityPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
||||
super("placer", BlockEntityPlacer::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(5);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,12 +3,12 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPotionGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockPotionGenerator() {
|
||||
super("potion_generator", BlockEntityPotionGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
|
||||
super("potion_generator", BlockEntityPotionGenerator::new, Properties.of(Material.STONE).strength(5F));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,21 +3,21 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPowderPlacer;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F);
|
||||
|
||||
public BlockPowderPlacer() {
|
||||
super("powder_placer", BlockEntityPowderPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
|
||||
super("powder_placer", BlockEntityPowderPlacer::new, Properties.of(Material.STONE).strength(2, 5F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,69 +1,62 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.dispenser.IPosition;
|
||||
import net.minecraft.dispenser.ProjectileDispenseBehavior;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.item.EnderPearlEntity;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.entity.projectile.TridentEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.tileentity.BlockEntityType;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
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.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
|
||||
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
|
||||
|
||||
public BlockProjectileGenerator() {
|
||||
super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
||||
super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
DispenserBlock.registerDispenseBehavior(Items.ENDER_PEARL, new ProjectileDispenseBehavior() {
|
||||
DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() {
|
||||
|
||||
@Override
|
||||
protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) {
|
||||
EnderPearlEntity ret = new EnderPearlEntity(EntityType.ENDER_PEARL, levelIn);
|
||||
ret.setPosition(position.getX(), position.getY(), position.getZ());
|
||||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||
var ret = new ThrownEnderpearl(EntityType.ENDER_PEARL, levelIn);
|
||||
ret.setPos(position.x(), position.y(), position.z());
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
DispenserBlock.registerDispenseBehavior(Items.TRIDENT, new ProjectileDispenseBehavior() {
|
||||
DispenserBlock.registerBehavior(Items.TRIDENT, new AbstractProjectileDispenseBehavior() {
|
||||
@Override
|
||||
protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) {
|
||||
TridentEntity ret = new TridentEntity(EntityType.TRIDENT, levelIn);
|
||||
ret.setPosition(position.getX(), position.getY(), position.getZ());
|
||||
// set thrownStack
|
||||
ObfuscationReflectionHelper.setPrivateValue(TridentEntity.class, ret, stackIn.copy(), "field_203054_h");
|
||||
ret.pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
|
||||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||
var ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
|
||||
ret.setPos(position.x(), position.y(), position.z());
|
||||
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "tridentItem");
|
||||
ret.pickup = AbstractArrow.Pickup.ALLOWED;
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
@ -71,23 +64,21 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
|
||||
@SubscribeEvent
|
||||
public void onProjectileImpact(ProjectileImpactEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
var entity = event.getEntity();
|
||||
if (entity.level.isClientSide)
|
||||
return;
|
||||
RayTraceResult ray = event.getRayTraceResult();
|
||||
if (!(ray instanceof BlockRayTraceResult))
|
||||
var ray = event.getRayTraceResult();
|
||||
if (!(ray instanceof BlockHitResult blockRay))
|
||||
return;
|
||||
BlockRayTraceResult blockRay = (BlockRayTraceResult) ray;
|
||||
BlockPos pos = blockRay.getPos();
|
||||
var pos = blockRay.getBlockPos();
|
||||
if (pos == null)
|
||||
return;
|
||||
BlockEntity tile = entity.level.getBlockEntity(pos);
|
||||
if (!(tile instanceof BlockEntityProjectileGenerator))
|
||||
var tile = entity.level.getBlockEntity(pos);
|
||||
if (!(tile instanceof BlockEntityProjectileGenerator generator))
|
||||
return;
|
||||
BlockEntityProjectileGenerator generator = (BlockEntityProjectileGenerator) tile;
|
||||
if (generator.nextSide != blockRay.getFace())
|
||||
if (generator.nextSide != blockRay.getDirection())
|
||||
return;
|
||||
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType());
|
||||
var amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType());
|
||||
if (amount == null || amount <= 0)
|
||||
return;
|
||||
if (!generator.canGenerateRightNow(amount))
|
||||
|
@ -95,21 +86,16 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
generator.generateAura(amount);
|
||||
|
||||
PacketHandler.sendToAllAround(entity.level, pos, 32,
|
||||
new PacketParticles((float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ()));
|
||||
entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
|
||||
new PacketParticles((float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ()));
|
||||
entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.BLOCKS, 0.8F, 1F);
|
||||
|
||||
generator.nextSide = generator.nextSide.rotateY();
|
||||
generator.nextSide = generator.nextSide.getClockWise();
|
||||
generator.sendToClients();
|
||||
|
||||
entity.remove();
|
||||
entity.kill();
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tuple<BlockEntityType<BlockEntityProjectileGenerator>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityProjectileGenerator>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.PROJECTILE_GENERATOR, () -> RenderProjectileGenerator::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||
|
@ -117,4 +103,9 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,17 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityRFConverter;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public class BlockRFConverter extends BlockContainerImpl {
|
||||
|
||||
public BlockRFConverter() {
|
||||
super("rf_converter", BlockEntityRFConverter::new, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3));
|
||||
super("rf_converter", BlockEntityRFConverter::new, Properties.of(Material.STONE).sound(SoundType.STONE).strength(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return ModConfig.instance.rfConverter.get() ? super.getTranslationKey() : "block." + NaturesAura.MOD_ID + "." + this.getBaseName() + ".disabled";
|
||||
public String getDescriptionId() {
|
||||
return ModConfig.instance.rfConverter.get() ? super.getDescriptionId() : "block." + NaturesAura.MOD_ID + "." + this.getBaseName() + ".disabled";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySlimeSplitGenerator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.monster.SlimeEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.monster.Slime;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -18,8 +18,9 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockSlimeSplitGenerator() {
|
||||
super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.from(Blocks.SLIME_BLOCK).hardnessAndResistance(2));
|
||||
super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.copy(Blocks.SLIME_BLOCK).strength(2));
|
||||
MinecraftForge.EVENT_BUS.register(new Events());
|
||||
}
|
||||
|
||||
|
@ -33,8 +34,8 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(8);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
return new AABB(pos).inflate(8);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,17 +48,15 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
|
|||
|
||||
@SubscribeEvent
|
||||
public void onLivingDeath(LivingDeathEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
if (!(entity instanceof SlimeEntity) || entity.level.isClientSide)
|
||||
var entity = event.getEntityLiving();
|
||||
if (!(entity instanceof Slime slime) || entity.level.isClientSide)
|
||||
return;
|
||||
SlimeEntity slime = (SlimeEntity) entity;
|
||||
int size = slime.getSlimeSize();
|
||||
var size = slime.getSize();
|
||||
if (size <= 1)
|
||||
return;
|
||||
Helper.getBlockEntitiesInArea(entity.level, entity.getPosition(), 8, tile -> {
|
||||
if (!(tile instanceof BlockEntitySlimeSplitGenerator))
|
||||
Helper.getBlockEntitiesInArea(entity.level, entity.blockPosition(), 8, tile -> {
|
||||
if (!(tile instanceof BlockEntitySlimeSplitGenerator gen))
|
||||
return false;
|
||||
BlockEntitySlimeSplitGenerator gen = (BlockEntitySlimeSplitGenerator) tile;
|
||||
if (gen.isBusy())
|
||||
return false;
|
||||
gen.startGenerating(slime);
|
||||
|
|
|
@ -4,27 +4,28 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySnowCreator;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockSnowCreator() {
|
||||
super("snow_creator", BlockEntitySnowCreator::new, Properties.from(Blocks.STONE_BRICKS));
|
||||
super("snow_creator", BlockEntitySnowCreator::new, Properties.copy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntitySnowCreator) {
|
||||
int radius = ((BlockEntitySnowCreator) tile).getRange();
|
||||
var radius = ((BlockEntitySnowCreator) tile).getRange();
|
||||
if (radius > 0)
|
||||
return new AxisAlignedBB(pos).grow(radius);
|
||||
return new AABB(pos).inflate(radius);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,22 +10,22 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
|
|||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.ILevel;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.level.server.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
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.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -40,7 +40,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);
|
||||
|
||||
public BlockSpawnLamp() {
|
||||
super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.create(Material.IRON).hardnessAndResistance(3F).setLightLevel(s -> 15).sound(SoundType.METAL));
|
||||
super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.of(Material.METAL).strength(3F).lightLevel(s -> 15).sound(SoundType.METAL));
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
|
@ -53,27 +53,27 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
|||
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if (event.getSpawner() != null)
|
||||
return;
|
||||
ILevel level = event.getLevel();
|
||||
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
|
||||
var level = event.getWorld();
|
||||
var pos = new BlockPos(event.getX(), event.getY(), event.getZ());
|
||||
if (!(level instanceof Level))
|
||||
return;
|
||||
LevelData data = (LevelData) ILevelData.getLevelData((Level) level);
|
||||
for (BlockEntitySpawnLamp lamp : data.spawnLamps) {
|
||||
var data = (LevelData) ILevelData.getLevelData((Level) level);
|
||||
for (var lamp : data.spawnLamps) {
|
||||
if (lamp.isRemoved())
|
||||
continue;
|
||||
|
||||
int range = lamp.getRadius();
|
||||
var range = lamp.getRadius();
|
||||
if (range <= 0)
|
||||
continue;
|
||||
|
||||
BlockPos lampPos = lamp.getPos();
|
||||
if (!new AxisAlignedBB(lampPos).grow(range).contains(new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)))
|
||||
var lampPos = lamp.getBlockPos();
|
||||
if (!new AABB(lampPos).inflate(range).contains(new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)))
|
||||
continue;
|
||||
|
||||
MobEntity entity = (MobEntity) event.getEntityLiving();
|
||||
if (entity.canSpawn(level, event.getSpawnReason()) && entity.isNotColliding(level)) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(level, lampPos, 32, lampPos);
|
||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 200);
|
||||
var entity = (Mob) event.getEntityLiving();
|
||||
if (entity.checkSpawnRules(level, event.getSpawnReason()) && entity.checkSpawnObstruction(level)) {
|
||||
var spot = IAuraChunk.getHighestSpot((Level) level, lampPos, 32, lampPos);
|
||||
IAuraChunk.getAuraChunk((Level) level, spot).drainAura(spot, 200);
|
||||
|
||||
PacketHandler.sendToAllAround((ServerLevel) level, lampPos, 32,
|
||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP));
|
||||
|
@ -85,18 +85,18 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntitySpawnLamp) {
|
||||
int radius = ((BlockEntitySpawnLamp) tile).getRadius();
|
||||
var radius = ((BlockEntitySpawnLamp) tile).getRadius();
|
||||
if (radius > 0)
|
||||
return new AxisAlignedBB(pos).grow(radius);
|
||||
return new AABB(pos).inflate(radius);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -114,6 +114,6 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
|||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getCutoutMipped;
|
||||
return RenderType::cutoutMipped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,46 +6,49 @@ import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
|
|||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.IBucketPickupHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.level.ILevel;
|
||||
import net.minecraft.level.biome.BiomeColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
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.material.Fluids;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, IBucketPickupHandler, ICustomRenderType {
|
||||
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, BucketPickup, ICustomRenderType {
|
||||
|
||||
public BlockSpring() {
|
||||
super("spring", BlockEntitySpring::new, Properties.from(Blocks.STONE_BRICKS));
|
||||
super("spring", BlockEntitySpring::new, Properties.copy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IBlockColor getBlockColor() {
|
||||
return (state, level, pos, i) -> BiomeColors.getWaterColor(level, pos);
|
||||
public BlockColor getBlockColor() {
|
||||
return (state, level, pos, i) -> BiomeColors.getAverageWaterColor(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SuppressWarnings("Convert2Lambda")
|
||||
public IItemColor getItemColor() {
|
||||
return new IItemColor() {
|
||||
public ItemColor getItemColor() {
|
||||
return new ItemColor() {
|
||||
@Override
|
||||
public int getColor(ItemStack stack, int i) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
return BiomeColors.getWaterColor(player.level, player.getPosition());
|
||||
return BiomeColors.getAverageWaterColor(player.level, player.blockPosition());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -55,16 +58,21 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
|
|||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid pickupFluid(ILevel levelIn, BlockPos pos, BlockState state) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntitySpring)
|
||||
((BlockEntitySpring) tile).consumeAura(2500);
|
||||
return Fluids.WATER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<RenderType> getRenderType() {
|
||||
return RenderType::getTranslucent;
|
||||
return RenderType::translucent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack pickupBlock(LevelAccessor levelIn, BlockPos pos, BlockState state) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntitySpring)
|
||||
((BlockEntitySpring) tile).consumeAura(2500);
|
||||
return new ItemStack(Items.WATER_BUCKET); }
|
||||
|
||||
@Override
|
||||
public Optional<SoundEvent> getPickupSound() {
|
||||
return Fluids.WATER.getPickupSound();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,19 +4,19 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockStairsNA extends StairsBlock implements IModItem, ICustomBlockState {
|
||||
public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockState {
|
||||
|
||||
public final String textureName;
|
||||
private final String baseName;
|
||||
|
||||
public BlockStairsNA(String baseName, String textureName, Supplier<BlockState> modelState, Block.Properties properties) {
|
||||
super(modelState, properties.variableOpacity());
|
||||
super(modelState, properties.dynamicShape());
|
||||
this.baseName = baseName;
|
||||
this.textureName = textureName;
|
||||
ModRegistry.add(this);
|
||||
|
|
|
@ -3,12 +3,13 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityTimeChanger;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockTimeChanger() {
|
||||
super("time_changer", BlockEntityTimeChanger::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
||||
super("time_changer", BlockEntityTimeChanger::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,11 +3,12 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWeatherChanger;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockWeatherChanger() {
|
||||
super("weather_changer", BlockEntityWeatherChanger::new, Properties.from(Blocks.STONE_BRICKS));
|
||||
super("weather_changer", BlockEntityWeatherChanger::new, Properties.copy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,53 +2,47 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
|
||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.entity.player.Player;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.tileentity.BlockEntityType;
|
||||
import net.minecraft.util.InteractionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.Shapes;
|
||||
import net.minecraft.level.IBlockReader;
|
||||
import net.minecraft.level.ILevel;
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
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.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.event.level.SaplingGrowTreeEvent;
|
||||
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.apache.commons.lang3.mutable.MutableObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<BlockEntityWoodStand>, ICustomBlockState {
|
||||
|
||||
private static final VoxelShape SHAPE = Shapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F);
|
||||
|
||||
public BlockWoodStand() {
|
||||
super("wood_stand", BlockEntityWoodStand::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
|
||||
super("wood_stand", BlockEntityWoodStand::new, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD));
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
|
@ -58,32 +52,31 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
ILevel level = event.getLevel();
|
||||
BlockPos pos = event.getPos();
|
||||
var level = event.getWorld();
|
||||
var pos = event.getPos();
|
||||
if (!level.isClientSide() && level instanceof Level) {
|
||||
if (Multiblocks.TREE_RITUAL.isComplete((Level) level, pos)) {
|
||||
BlockState sapling = level.getBlockState(pos);
|
||||
ItemStack saplingStack = sapling.getBlock().getItem(level, pos, sapling);
|
||||
var sapling = level.getBlockState(pos);
|
||||
var saplingStack = sapling.getBlock().getCloneItemStack(level, pos, sapling);
|
||||
if (!saplingStack.isEmpty()) {
|
||||
for (TreeRitualRecipe recipe : ((Level) level).getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null)) {
|
||||
for (var recipe : ((Level) level).getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, null)) {
|
||||
if (recipe.saplingType.test(saplingStack)) {
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||
MutableObject<BlockEntityWoodStand> toPick = new MutableObject<>();
|
||||
var toPick = new MutableObject<BlockEntityWoodStand>();
|
||||
|
||||
boolean fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> {
|
||||
BlockEntity tile = level.getBlockEntity(tilePos);
|
||||
if (tile instanceof BlockEntityWoodStand) {
|
||||
BlockEntityWoodStand stand = (BlockEntityWoodStand) tile;
|
||||
ItemStack stack = stand.items.getStackInSlot(0);
|
||||
var fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> {
|
||||
var tile = level.getBlockEntity(tilePos);
|
||||
if (tile instanceof BlockEntityWoodStand stand) {
|
||||
var stack = stand.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
for (int i = required.size() - 1; i >= 0; i--) {
|
||||
Ingredient req = required.get(i);
|
||||
for (var i = required.size() - 1; i >= 0; i--) {
|
||||
var req = required.get(i);
|
||||
if (req.test(stack)) {
|
||||
required.remove(i);
|
||||
|
||||
|
@ -111,17 +104,17 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tuple<BlockEntityType<BlockEntityWoodStand>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityWoodStand>>>> getTESR() {
|
||||
return new Tuple<>(ModTileEntities.WOOD_STAND, () -> RenderWoodStand::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModTileEntities.WOOD_STAND, RenderWoodStand::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,24 +29,24 @@ public class Multiblock implements IMultiblock {
|
|||
public Multiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) {
|
||||
this.name = name;
|
||||
|
||||
int width = -1;
|
||||
var width = -1;
|
||||
this.height = pattern.length;
|
||||
int depth = -1;
|
||||
int xOff = 0;
|
||||
int yOff = 0;
|
||||
int zOff = 0;
|
||||
var depth = -1;
|
||||
var xOff = 0;
|
||||
var yOff = 0;
|
||||
var zOff = 0;
|
||||
char[][][] raw = null;
|
||||
|
||||
for (int i = 0; i < pattern.length; i++) {
|
||||
String[] row = pattern[i];
|
||||
for (var i = 0; i < pattern.length; i++) {
|
||||
var row = pattern[i];
|
||||
|
||||
if (width < 0)
|
||||
width = row.length;
|
||||
else if (row.length != width)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
for (int j = 0; j < row.length; j++) {
|
||||
String column = row[j];
|
||||
for (var j = 0; j < row.length; j++) {
|
||||
var column = row[j];
|
||||
if (depth < 0)
|
||||
depth = column.length();
|
||||
else if (column.length() != depth)
|
||||
|
@ -54,8 +54,8 @@ public class Multiblock implements IMultiblock {
|
|||
|
||||
if (raw == null)
|
||||
raw = new char[width][this.height][depth];
|
||||
for (int k = 0; k < column.length(); k++) {
|
||||
char c = column.charAt(k);
|
||||
for (var k = 0; k < column.length(); k++) {
|
||||
var c = column.charAt(k);
|
||||
raw[k][this.height - 1 - i][j] = c;
|
||||
|
||||
if (c == '0') {
|
||||
|
@ -74,12 +74,12 @@ public class Multiblock implements IMultiblock {
|
|||
this.rawPattern = raw;
|
||||
|
||||
Map<Character, Matcher> matchers = new HashMap<>();
|
||||
for (int i = 0; i < rawMatchers.length; i += 2) {
|
||||
char c = (char) rawMatchers[i];
|
||||
for (var i = 0; i < rawMatchers.length; i += 2) {
|
||||
var c = (char) rawMatchers[i];
|
||||
if (matchers.containsKey(c))
|
||||
continue;
|
||||
|
||||
Object value = rawMatchers[i + 1];
|
||||
var value = rawMatchers[i + 1];
|
||||
if (value instanceof BlockState state) {
|
||||
matchers.put(c, new Matcher(state,
|
||||
(level, start, offset, pos, other, otherC) -> other == state));
|
||||
|
@ -90,13 +90,13 @@ public class Multiblock implements IMultiblock {
|
|||
matchers.put(c, (Matcher) value);
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.width; x++)
|
||||
for (int y = 0; y < this.height; y++)
|
||||
for (int z = 0; z < this.depth; z++) {
|
||||
Matcher matcher = matchers.get(this.rawPattern[x][y][z]);
|
||||
for (var x = 0; x < this.width; x++)
|
||||
for (var y = 0; y < this.height; y++)
|
||||
for (var z = 0; z < this.depth; z++) {
|
||||
var matcher = matchers.get(this.rawPattern[x][y][z]);
|
||||
if (matcher == null)
|
||||
throw new IllegalStateException();
|
||||
if (matcher.getCheck() != null)
|
||||
if (matcher.check() != null)
|
||||
this.matchers.put(new BlockPos(x, y, z), matcher);
|
||||
}
|
||||
|
||||
|
@ -106,18 +106,18 @@ public class Multiblock implements IMultiblock {
|
|||
|
||||
@Override
|
||||
public boolean isComplete(Level level, BlockPos center) {
|
||||
BlockPos start = this.getStart(center);
|
||||
var start = this.getStart(center);
|
||||
return this.forEach(center, (char) 0, (pos, matcher) -> {
|
||||
BlockPos offset = pos.subtract(start);
|
||||
return matcher.getCheck().matches(level, start, offset, pos, level.getBlockState(pos), this.getChar(offset));
|
||||
var offset = pos.subtract(start);
|
||||
return matcher.check().matches(level, start, offset, pos, level.getBlockState(pos), this.getChar(offset));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forEach(BlockPos center, char c, BiFunction<BlockPos, Matcher, Boolean> function) {
|
||||
BlockPos start = this.getStart(center);
|
||||
for (Map.Entry<BlockPos, Matcher> entry : this.matchers.entrySet()) {
|
||||
BlockPos offset = entry.getKey();
|
||||
var start = this.getStart(center);
|
||||
for (var entry : this.matchers.entrySet()) {
|
||||
var offset = entry.getKey();
|
||||
if (c == 0 || this.getChar(offset) == c)
|
||||
if (!function.apply(start.offset(offset), entry.getValue()))
|
||||
return false;
|
||||
|
|
|
@ -53,7 +53,7 @@ public final class Multiblocks {
|
|||
return true;
|
||||
// try-catch to prevent blocks that need to have been placed crashing here
|
||||
try {
|
||||
ItemStack stack = state.getBlock().getCloneItemStack(level, pos, state);
|
||||
var stack = state.getBlock().getCloneItemStack(level, pos, state);
|
||||
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, null).stream().anyMatch(r -> r.saplingType.test(stack));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
|
|
@ -17,7 +17,7 @@ public class BlockEntityAncientLeaves extends BlockEntityImpl {
|
|||
|
||||
@Override
|
||||
public int drainAura(int amountToDrain, boolean simulate) {
|
||||
int amount = super.drainAura(amountToDrain, simulate);
|
||||
var amount = super.drainAura(amountToDrain, simulate);
|
||||
if (amount > 0 && !simulate) {
|
||||
BlockEntityAncientLeaves.this.sendToClients();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockEntityAnimalGenerator extends BlockEntityImpl implements ITick
|
|||
if (this.timeRemaining <= 0)
|
||||
return;
|
||||
|
||||
int remain = this.amountToRelease;
|
||||
var remain = this.amountToRelease;
|
||||
if (this.canGenerateRightNow(remain)) {
|
||||
this.generateAura(remain);
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
|
|
|
@ -51,13 +51,13 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
}
|
||||
|
||||
if (this.currentRecipe != null) {
|
||||
int drain = Mth.ceil(this.currentRecipe.aura / (float) this.currentRecipe.time * 10F);
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var drain = Mth.ceil(this.currentRecipe.aura / (float) this.currentRecipe.time * 10F);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, drain);
|
||||
|
||||
this.time += 10;
|
||||
if (this.time >= this.currentRecipe.time) {
|
||||
Entity entity = this.currentRecipe.makeEntity(this.level, new BlockPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ));
|
||||
var entity = this.currentRecipe.makeEntity(this.level, new BlockPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ));
|
||||
this.level.addFreshEntity(entity);
|
||||
|
||||
this.currentRecipe = null;
|
||||
|
@ -65,20 +65,20 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
this.sendToClients();
|
||||
}
|
||||
} else {
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class,
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class,
|
||||
new AABB(this.worldPosition).inflate(2));
|
||||
|
||||
for (AnimalSpawnerRecipe recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) {
|
||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) {
|
||||
if (recipe.ingredients.length != items.size())
|
||||
continue;
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||
for (ItemEntity item : items) {
|
||||
for (var item : items) {
|
||||
if (!item.isAlive() || item.hasPickUpDelay())
|
||||
break;
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
break;
|
||||
for (Ingredient ingredient : required) {
|
||||
for (var ingredient : required) {
|
||||
if (ingredient.test(stack) && Helper.getIngredientAmount(ingredient) == stack.getCount()) {
|
||||
required.remove(ingredient);
|
||||
break;
|
||||
|
@ -88,7 +88,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
if (!required.isEmpty())
|
||||
continue;
|
||||
|
||||
for (ItemEntity item : items) {
|
||||
for (var item : items) {
|
||||
item.remove(Entity.RemovalReason.KILLED);
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER));
|
||||
|
@ -124,8 +124,8 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
this.entityClient = this.currentRecipe.makeEntity(this.level, BlockPos.ZERO);
|
||||
this.entityClient.setPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ);
|
||||
}
|
||||
AABB bounds = this.entityClient.getBoundingBox();
|
||||
for (int i = this.level.random.nextInt(5) + 5; i >= 0; i--)
|
||||
var bounds = this.entityClient.getBoundingBox();
|
||||
for (var i = this.level.random.nextInt(5) + 5; i >= 0; i--)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
bounds.minX + this.level.random.nextFloat() * (bounds.maxX - bounds.minX),
|
||||
bounds.minY + this.level.random.nextFloat() * (bounds.maxY - bounds.minY),
|
||||
|
@ -153,7 +153,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
if (type != SaveType.BLOCK) {
|
||||
if (compound.contains("recipe")) {
|
||||
if (this.hasLevel()) {
|
||||
ResourceLocation name = new ResourceLocation(compound.getString("recipe"));
|
||||
var name = new ResourceLocation(compound.getString("recipe"));
|
||||
this.currentRecipe = (AnimalSpawnerRecipe) this.level.getRecipeManager().byKey(name).orElse(null);
|
||||
}
|
||||
this.spawnX = compound.getDouble("spawn_x");
|
||||
|
|
|
@ -16,8 +16,8 @@ public class BlockEntityAuraDetector extends BlockEntityImpl implements ITickabl
|
|||
@Override
|
||||
public void tick() {
|
||||
if (!this.level.isClientSide && this.level.getGameTime() % 20 == 0) {
|
||||
int totalAmount = IAuraChunk.triangulateAuraInArea(this.level, this.worldPosition, 25);
|
||||
int power = Mth.clamp(Mth.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
|
||||
var totalAmount = IAuraChunk.triangulateAuraInArea(this.level, this.worldPosition, 25);
|
||||
var power = Mth.clamp(Mth.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
|
||||
if (this.redstonePower != power) {
|
||||
this.redstonePower = power;
|
||||
this.level.updateNeighbourForOutputSignal(this.worldPosition, this.getBlockState().getBlock());
|
||||
|
|
|
@ -38,7 +38,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
public void onRedstonePowerChange(int newPower) {
|
||||
if (this.redstonePower <= 0 && newPower > 0) {
|
||||
this.timer = 0;
|
||||
int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||
var color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.TIMER_RESET, color));
|
||||
this.sendToClients();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
int total = this.getTotalTime();
|
||||
var total = this.getTotalTime();
|
||||
if (total <= 0) {
|
||||
this.timer = 0;
|
||||
return;
|
||||
|
@ -55,7 +55,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
|
||||
if (this.level.isClientSide) {
|
||||
if (this.level.getGameTime() % 8 == 0) {
|
||||
int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||
var color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
this.worldPosition.getX() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
||||
this.worldPosition.getY() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
||||
|
@ -69,11 +69,11 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
if (this.timer >= total) {
|
||||
this.timer = 0;
|
||||
|
||||
BlockState state = this.getBlockState();
|
||||
var state = this.getBlockState();
|
||||
this.level.setBlock(this.worldPosition, state.setValue(BlockStateProperties.POWERED, true), 1);
|
||||
this.level.scheduleTick(this.worldPosition, state.getBlock(), 4);
|
||||
|
||||
int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||
var color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.TIMER_RESET, color));
|
||||
}
|
||||
if (this.timer % 2 == 0)
|
||||
|
@ -81,10 +81,10 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
}
|
||||
|
||||
public int getTotalTime() {
|
||||
ItemStack stack = this.itemHandler.getStackInSlot(0);
|
||||
var stack = this.itemHandler.getStackInSlot(0);
|
||||
if (stack.isEmpty())
|
||||
return 0;
|
||||
Integer amount = TIMES.get(ItemAuraBottle.getType(stack));
|
||||
var amount = TIMES.get(ItemAuraBottle.getType(stack));
|
||||
if (amount == null)
|
||||
return 0;
|
||||
return amount * stack.getCount();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
|
|||
this.crafting.clearContent();
|
||||
|
||||
var state = this.level.getBlockState(this.worldPosition);
|
||||
Direction facing = state.getValue(BlockAutoCrafter.FACING);
|
||||
var facing = state.getValue(BlockAutoCrafter.FACING);
|
||||
var middlePos = this.worldPosition.above();
|
||||
var topPos = middlePos.relative(facing, 2);
|
||||
var bottomPos = middlePos.relative(facing.getOpposite(), 2);
|
||||
|
|
|
@ -30,7 +30,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
if (this.level.isClientSide)
|
||||
return;
|
||||
|
||||
BlockEntity below = this.level.getBlockEntity(this.worldPosition.below());
|
||||
var below = this.level.getBlockEntity(this.worldPosition.below());
|
||||
if (!(below instanceof BlastFurnaceBlockEntity tile))
|
||||
return;
|
||||
Recipe<?> recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null);
|
||||
|
@ -39,8 +39,8 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
if (!this.isApplicable(recipe.getIngredients()))
|
||||
return;
|
||||
|
||||
ContainerData data = BlockEntityFurnaceHeater.getFurnaceData(tile);
|
||||
int doneDiff = data.get(3) - data.get(2);
|
||||
var data = BlockEntityFurnaceHeater.getFurnaceData(tile);
|
||||
var doneDiff = data.get(3) - data.get(2);
|
||||
if (doneDiff > 1)
|
||||
return;
|
||||
|
||||
|
@ -50,18 +50,18 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
return;
|
||||
}
|
||||
|
||||
ItemStack output = tile.getItem(2);
|
||||
var output = tile.getItem(2);
|
||||
if (output.getCount() >= output.getMaxStackSize())
|
||||
return;
|
||||
|
||||
if (output.isEmpty()) {
|
||||
ItemStack result = recipe.getResultItem();
|
||||
var result = recipe.getResultItem();
|
||||
tile.setItem(2, result.copy());
|
||||
} else {
|
||||
output.grow(1);
|
||||
}
|
||||
|
||||
BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition);
|
||||
var pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, 6500);
|
||||
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
|
@ -69,8 +69,8 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
}
|
||||
|
||||
private boolean isApplicable(List<Ingredient> ingredients) {
|
||||
for (Ingredient ing : ingredients) {
|
||||
for (ItemStack stack : ing.getItems()) {
|
||||
for (var ing : ingredients) {
|
||||
for (var stack : ing.getItems()) {
|
||||
if (stack.getItem().getTags().stream().anyMatch(t -> t.getPath().startsWith("ores/")))
|
||||
return true;
|
||||
}
|
||||
|
@ -80,10 +80,10 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
BlockEntity below = this.level.getBlockEntity(this.worldPosition.below());
|
||||
var below = this.level.getBlockEntity(this.worldPosition.below());
|
||||
if (!(below instanceof BlastFurnaceBlockEntity))
|
||||
return null;
|
||||
IItemHandler handler = below.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
var handler = below.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
if (handler == null)
|
||||
return null;
|
||||
return new IItemHandlerModifiable() {
|
||||
|
|
|
@ -34,8 +34,8 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
|||
return;
|
||||
if (this.currentlyBreaking.isEmpty())
|
||||
return;
|
||||
BlockPos pos = this.currentlyBreaking.removeLast();
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
var pos = this.currentlyBreaking.removeLast();
|
||||
var state = this.level.getBlockState(pos);
|
||||
if (state.getBlock() != Blocks.CHORUS_PLANT && state.getBlock() != Blocks.CHORUS_FLOWER) {
|
||||
this.currentlyBreaking.clear();
|
||||
return;
|
||||
|
@ -50,16 +50,16 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
|||
@Override
|
||||
public void onRedstonePowerChange(int newPower) {
|
||||
if (this.redstonePower <= 0 && newPower > 0 && this.currentlyBreaking.isEmpty()) {
|
||||
int range = 2;
|
||||
var range = 2;
|
||||
xyz:
|
||||
for (int x = -range; x <= range; x++) {
|
||||
for (int y = -range; y <= range; y++) {
|
||||
for (int z = -range; z <= range; z++) {
|
||||
BlockPos offset = this.worldPosition.offset(x, y, z);
|
||||
BlockState below = this.level.getBlockState(offset.below());
|
||||
for (var x = -range; x <= range; x++) {
|
||||
for (var y = -range; y <= range; y++) {
|
||||
for (var z = -range; z <= range; z++) {
|
||||
var offset = this.worldPosition.offset(x, y, z);
|
||||
var below = this.level.getBlockState(offset.below());
|
||||
if (below.getBlock() != Blocks.END_STONE)
|
||||
continue;
|
||||
BlockState state = this.level.getBlockState(offset);
|
||||
var state = this.level.getBlockState(offset);
|
||||
if (state.getBlock() != Blocks.CHORUS_PLANT)
|
||||
continue;
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
|||
this.currentlyBreaking.addAll(plants);
|
||||
this.currentlyBreaking.addFirst(offset);
|
||||
|
||||
int aura = plants.size() * plants.size() * 300;
|
||||
var aura = plants.size() * plants.size() * 300;
|
||||
this.auraPerBlock = aura / plants.size();
|
||||
|
||||
break xyz;
|
||||
|
@ -82,13 +82,13 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
|||
}
|
||||
|
||||
private void collectChorusPlant(BlockPos pos, List<BlockPos> blocks) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
for (var dir : Direction.values()) {
|
||||
if (dir == Direction.DOWN)
|
||||
continue;
|
||||
BlockPos offset = pos.relative(dir);
|
||||
var offset = pos.relative(dir);
|
||||
if (blocks.contains(offset))
|
||||
continue;
|
||||
BlockState state = this.level.getBlockState(offset);
|
||||
var state = this.level.getBlockState(offset);
|
||||
if (state.getBlock() != Blocks.CHORUS_PLANT && state.getBlock() != Blocks.CHORUS_FLOWER)
|
||||
continue;
|
||||
blocks.add(offset);
|
||||
|
@ -100,8 +100,8 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
|||
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
if (type == SaveType.TILE) {
|
||||
ListTag list = new ListTag();
|
||||
for (BlockPos pos : this.currentlyBreaking)
|
||||
var list = new ListTag();
|
||||
for (var pos : this.currentlyBreaking)
|
||||
list.add(NbtUtils.writeBlockPos(pos));
|
||||
compound.put("breaking", list);
|
||||
compound.putInt("aura", this.auraPerBlock);
|
||||
|
@ -113,8 +113,8 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
|||
super.readNBT(compound, type);
|
||||
if (type == SaveType.TILE) {
|
||||
this.currentlyBreaking.clear();
|
||||
ListTag list = compound.getList("breaking", 10);
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
var list = compound.getList("breaking", 10);
|
||||
for (var i = 0; i < list.size(); i++)
|
||||
this.currentlyBreaking.add(NbtUtils.readBlockPos(list.getCompound(i)));
|
||||
this.auraPerBlock = compound.getInt("aura");
|
||||
}
|
||||
|
|
|
@ -45,15 +45,15 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable
|
|||
private void loadChunks(boolean unload) {
|
||||
if (this.level.isClientSide || !ModConfig.instance.chunkLoader.get())
|
||||
return;
|
||||
ServerLevel level = (ServerLevel) this.level;
|
||||
var level = (ServerLevel) this.level;
|
||||
|
||||
List<ChunkPos> shouldBeForced = new ArrayList<>();
|
||||
if (!unload) {
|
||||
int range = this.range();
|
||||
var range = this.range();
|
||||
if (range > 0) {
|
||||
for (int x = (this.worldPosition.getX() - range) >> 4; x <= (this.worldPosition.getX() + range) >> 4; x++) {
|
||||
for (int z = (this.worldPosition.getZ() - range) >> 4; z <= (this.worldPosition.getZ() + range) >> 4; z++) {
|
||||
ChunkPos pos = new ChunkPos(x, z);
|
||||
for (var x = (this.worldPosition.getX() - range) >> 4; x <= (this.worldPosition.getX() + range) >> 4; x++) {
|
||||
for (var z = (this.worldPosition.getZ() - range) >> 4; z <= (this.worldPosition.getZ() + range) >> 4; z++) {
|
||||
var pos = new ChunkPos(x, z);
|
||||
// Only force chunks that we're already forcing or that nobody else is forcing
|
||||
if (this.forcedChunks.contains(pos) || !level.getForcedChunks().contains(pos.toLong()))
|
||||
shouldBeForced.add(pos);
|
||||
|
@ -63,14 +63,14 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
|
||||
// Unforce all the chunks that shouldn't be forced anymore
|
||||
for (ChunkPos pos : this.forcedChunks) {
|
||||
for (var pos : this.forcedChunks) {
|
||||
if (!shouldBeForced.contains(pos))
|
||||
level.setChunkForced(pos.x, pos.z, false);
|
||||
}
|
||||
this.forcedChunks.clear();
|
||||
|
||||
// Force all chunks that should be forced
|
||||
for (ChunkPos pos : shouldBeForced) {
|
||||
for (var pos : shouldBeForced) {
|
||||
level.setChunkForced(pos.x, pos.z, true);
|
||||
this.forcedChunks.add(pos);
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable
|
|||
|
||||
if (this.level.getGameTime() % 20 != 0)
|
||||
return;
|
||||
int toUse = Mth.ceil(this.range() / 2F);
|
||||
var toUse = Mth.ceil(this.range() / 2F);
|
||||
if (toUse > 0) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, toUse);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
|||
|
||||
@Override
|
||||
public int drainAura(int amountToDrain, boolean simulate) {
|
||||
int amount = super.drainAura(amountToDrain, simulate);
|
||||
var amount = super.drainAura(amountToDrain, simulate);
|
||||
if (amount > 0 && !simulate)
|
||||
BlockEntityEndFlower.this.sendToClients();
|
||||
return amount;
|
||||
|
@ -56,11 +56,11 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
|||
return;
|
||||
|
||||
if (!this.isDrainMode) {
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(1), Entity::isAlive);
|
||||
for (ItemEntity item : items) {
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(1), Entity::isAlive);
|
||||
for (var item : items) {
|
||||
if (item.hasPickUpDelay())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (stack.getCount() != 1)
|
||||
continue;
|
||||
if (stack.getItem() != Items.ENDER_EYE)
|
||||
|
@ -74,7 +74,7 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
int toDrain = Math.min(5000, this.container.getStoredAura());
|
||||
var toDrain = Math.min(5000, this.container.getStoredAura());
|
||||
this.container.drainAura(toDrain, false);
|
||||
this.generateAura(toDrain);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
|||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
ItemStack remain = this.getStorage().insertItem(slot, stack, simulate);
|
||||
var remain = this.getStorage().insertItem(slot, stack, simulate);
|
||||
if (!simulate)
|
||||
BlockEntityEnderCrate.this.drainAura((stack.getCount() - remain.getCount()) * 20);
|
||||
return remain;
|
||||
|
@ -54,7 +54,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
|||
@Nonnull
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
ItemStack extracted = this.getStorage().extractItem(slot, amount, simulate);
|
||||
var extracted = this.getStorage().extractItem(slot, amount, simulate);
|
||||
if (!simulate)
|
||||
BlockEntityEnderCrate.this.drainAura(extracted.getCount() * 20);
|
||||
return extracted;
|
||||
|
@ -107,7 +107,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
|||
public void loadDataOnPlace(ItemStack stack) {
|
||||
super.loadDataOnPlace(stack);
|
||||
if (!this.level.isClientSide) {
|
||||
String name = BlockEnderCrate.getEnderName(stack);
|
||||
var name = BlockEnderCrate.getEnderName(stack);
|
||||
if (name != null && !name.isEmpty())
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
|||
|
||||
public void drainAura(int amount) {
|
||||
if (amount > 0) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
if (this.level.isClientSide || this.level.getGameTime() % 10 != 0)
|
||||
return;
|
||||
|
||||
BlockPos connectedPos = this.getConnectedPos();
|
||||
var connectedPos = this.getConnectedPos();
|
||||
if (connectedPos == null || !this.level.isLoaded(connectedPos))
|
||||
return;
|
||||
|
||||
BlockEntity other = this.level.getBlockEntity(connectedPos);
|
||||
var other = this.level.getBlockEntity(connectedPos);
|
||||
if (!this.isCloseEnough(connectedPos)
|
||||
|| !(other instanceof BlockEntityFieldCreator)
|
||||
|| !this.worldPosition.equals(((BlockEntityFieldCreator) other).getConnectedPos())) {
|
||||
|
@ -61,7 +61,7 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
if (!this.isMain)
|
||||
return;
|
||||
|
||||
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) other;
|
||||
var creator = (BlockEntityFieldCreator) other;
|
||||
if (this.redstonePower <= 0 && creator.redstonePower <= 0) {
|
||||
this.chargeTimer = 0;
|
||||
if (this.isCharged) {
|
||||
|
@ -73,8 +73,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
return;
|
||||
}
|
||||
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 32, this.worldPosition);
|
||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 32, this.worldPosition);
|
||||
var chunk = IAuraChunk.getAuraChunk(this.level, spot);
|
||||
|
||||
if (!this.isCharged) {
|
||||
this.chargeTimer += 10;
|
||||
|
@ -93,17 +93,17 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
if (this.level.getGameTime() % 40 == 0)
|
||||
chunk.drainAura(spot, 20);
|
||||
|
||||
ItemStack tool = this.getToolUsed(creator);
|
||||
Vec3 dist = new Vec3(
|
||||
var tool = this.getToolUsed(creator);
|
||||
var dist = new Vec3(
|
||||
this.worldPosition.getX() - connectedPos.getX(),
|
||||
this.worldPosition.getY() - connectedPos.getY(),
|
||||
this.worldPosition.getZ() - connectedPos.getZ()
|
||||
);
|
||||
double length = dist.length();
|
||||
Vec3 normal = new Vec3(dist.x / length, dist.y / length, dist.z / length);
|
||||
var length = dist.length();
|
||||
var normal = new Vec3(dist.x / length, dist.y / length, dist.z / length);
|
||||
for (float i = Mth.floor(length); i > 0; i -= 0.5F) {
|
||||
Vec3 scaled = normal.scale(i);
|
||||
BlockPos pos = connectedPos.offset(
|
||||
var scaled = normal.scale(i);
|
||||
var pos = connectedPos.offset(
|
||||
Mth.floor(scaled.x + 0.5F),
|
||||
Mth.floor(scaled.y + 0.5F),
|
||||
Mth.floor(scaled.z + 0.5F));
|
||||
|
@ -111,19 +111,19 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
if (pos.equals(this.worldPosition) || pos.equals(connectedPos))
|
||||
continue;
|
||||
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
var state = this.level.getBlockState(pos);
|
||||
var block = state.getBlock();
|
||||
if (!state.isAir() && state.getDestroySpeed(this.level, pos) >= 0F) {
|
||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
||||
var fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
||||
if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.level, pos, state, fake))) {
|
||||
List<ItemStack> drops = state.getDrops(new LootContext.Builder((ServerLevel) this.level)
|
||||
var drops = state.getDrops(new LootContext.Builder((ServerLevel) this.level)
|
||||
.withParameter(LootContextParams.THIS_ENTITY, fake)
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
|
||||
.withParameter(LootContextParams.BLOCK_STATE, state)
|
||||
.withParameter(LootContextParams.TOOL, tool.isEmpty() ? new ItemStack(Items.DIAMOND_PICKAXE) : tool)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, this.level.getBlockEntity(pos)));
|
||||
this.level.destroyBlock(pos, false);
|
||||
for (ItemStack stack : drops)
|
||||
for (var stack : drops)
|
||||
Block.popResource(this.level, pos, stack);
|
||||
chunk.drainAura(spot, !tool.isEmpty() ? 300 : 100);
|
||||
this.sendParticles();
|
||||
|
@ -134,8 +134,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
}
|
||||
|
||||
private ItemStack getToolUsed(BlockEntityFieldCreator other) {
|
||||
ItemStack myTool = this.getMyTool();
|
||||
ItemStack otherTool = other.getMyTool();
|
||||
var myTool = this.getMyTool();
|
||||
var otherTool = other.getMyTool();
|
||||
if (!myTool.isEmpty()) {
|
||||
// if both have tools, choose randomly
|
||||
if (!otherTool.isEmpty())
|
||||
|
@ -146,9 +146,9 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
}
|
||||
|
||||
private ItemStack getMyTool() {
|
||||
List<ItemFrame> frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
for (ItemFrame frame : frames) {
|
||||
ItemStack stack = frame.getItem();
|
||||
var frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
for (var frame : frames) {
|
||||
var stack = frame.getItem();
|
||||
if (!stack.isEmpty())
|
||||
return stack;
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
}
|
||||
|
||||
private void sendParticles() {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
BlockPos p = j == 0 ? this.worldPosition : this.getConnectedPos();
|
||||
for (var j = 0; j < 2; j++) {
|
||||
var p = j == 0 ? this.worldPosition : this.getConnectedPos();
|
||||
PacketHandler.sendToAllAround(this.level, p, 32, new PacketParticleStream(
|
||||
p.getX() + (float) this.level.random.nextGaussian() * 3F,
|
||||
p.getY() + 1 + this.level.random.nextFloat() * 3F,
|
||||
|
@ -171,7 +171,7 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
}
|
||||
|
||||
public boolean isCloseEnough(BlockPos pos) {
|
||||
int range = ModConfig.instance.fieldCreatorRange.get() + 1;
|
||||
var range = ModConfig.instance.fieldCreatorRange.get() + 1;
|
||||
return this.worldPosition.distSqr(pos) <= range * range;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,15 +36,15 @@ public class BlockEntityFireworkGenerator extends BlockEntityImpl implements ITi
|
|||
public void tick() {
|
||||
if (!this.level.isClientSide) {
|
||||
if (this.level.getGameTime() % 10 == 0) {
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(4), Entity::isAlive);
|
||||
for (ItemEntity item : items) {
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(4), Entity::isAlive);
|
||||
for (var item : items) {
|
||||
if (item.hasPickUpDelay())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (stack.isEmpty() || stack.getItem() != Items.FIREWORK_ROCKET)
|
||||
continue;
|
||||
if (this.trackedEntity == null && this.releaseTimer <= 0) {
|
||||
FireworkRocketEntity entity = new FireworkRocketEntity(this.level, item.getX(), item.getY(), item.getZ(), stack);
|
||||
var entity = new FireworkRocketEntity(this.level, item.getX(), item.getY(), item.getZ(), stack);
|
||||
this.trackedEntity = entity;
|
||||
this.trackedItem = stack.copy();
|
||||
this.level.addFreshEntity(entity);
|
||||
|
@ -63,31 +63,31 @@ public class BlockEntityFireworkGenerator extends BlockEntityImpl implements ITi
|
|||
float generateFactor = 0;
|
||||
Set<Integer> usedColors = new HashSet<>();
|
||||
|
||||
CompoundTag compound = this.trackedItem.getTag();
|
||||
CompoundTag fireworks = compound.getCompound("Fireworks");
|
||||
var compound = this.trackedItem.getTag();
|
||||
var fireworks = compound.getCompound("Fireworks");
|
||||
|
||||
int flightTime = fireworks.getInt("Flight");
|
||||
ListTag explosions = fireworks.getList("Explosions", 10);
|
||||
var flightTime = fireworks.getInt("Flight");
|
||||
var explosions = fireworks.getList("Explosions", 10);
|
||||
if (!explosions.isEmpty()) {
|
||||
generateFactor += flightTime;
|
||||
|
||||
for (Tag base : explosions) {
|
||||
CompoundTag explosion = (CompoundTag) base;
|
||||
for (var base : explosions) {
|
||||
var explosion = (CompoundTag) base;
|
||||
generateFactor += 1.5F;
|
||||
|
||||
boolean flicker = explosion.getBoolean("Flicker");
|
||||
var flicker = explosion.getBoolean("Flicker");
|
||||
if (flicker)
|
||||
generateFactor += 1;
|
||||
|
||||
boolean trail = explosion.getBoolean("Trail");
|
||||
var trail = explosion.getBoolean("Trail");
|
||||
if (trail)
|
||||
generateFactor += 8;
|
||||
|
||||
byte type = explosion.getByte("Type");
|
||||
var type = explosion.getByte("Type");
|
||||
generateFactor += new float[]{0, 1, 0.5F, 20, 0.5F}[type];
|
||||
|
||||
Set<Integer> colors = new HashSet<>();
|
||||
for (int color : explosion.getIntArray("Colors")) {
|
||||
for (var color : explosion.getIntArray("Colors")) {
|
||||
usedColors.add(color);
|
||||
colors.add(color);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class BlockEntityFireworkGenerator extends BlockEntityImpl implements ITi
|
|||
}
|
||||
|
||||
if (generateFactor > 0) {
|
||||
int toAdd = Mth.ceil(generateFactor * 10000F);
|
||||
var toAdd = Mth.ceil(generateFactor * 10000F);
|
||||
if (this.canGenerateRightNow(toAdd)) {
|
||||
this.toRelease = toAdd;
|
||||
this.releaseTimer = 15 * flightTime + 40;
|
||||
|
|
|
@ -34,12 +34,12 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
public void tick() {
|
||||
if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) {
|
||||
List<BlockPos> possible = new ArrayList<>();
|
||||
int range = 3;
|
||||
for (int x = -range; x <= range; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -range; z <= range; z++) {
|
||||
BlockPos offset = this.worldPosition.offset(x, y, z);
|
||||
BlockState state = this.level.getBlockState(offset);
|
||||
var range = 3;
|
||||
for (var x = -range; x <= range; x++) {
|
||||
for (var y = -1; y <= 1; y++) {
|
||||
for (var z = -range; z <= range; z++) {
|
||||
var offset = this.worldPosition.offset(x, y, z);
|
||||
var state = this.level.getBlockState(offset);
|
||||
if (BlockTags.SMALL_FLOWERS.contains(state.getBlock()))
|
||||
possible.add(offset);
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
if (possible.isEmpty())
|
||||
return;
|
||||
|
||||
BlockPos pos = possible.get(this.level.random.nextInt(possible.size()));
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
MutableInt curr = this.consumedRecently.computeIfAbsent(state, s -> new MutableInt());
|
||||
var pos = possible.get(this.level.random.nextInt(possible.size()));
|
||||
var state = this.level.getBlockState(pos);
|
||||
var curr = this.consumedRecently.computeIfAbsent(state, s -> new MutableInt());
|
||||
|
||||
int addAmount = 25000;
|
||||
int toAdd = Math.max(0, addAmount - curr.getValue() * 100);
|
||||
var addAmount = 25000;
|
||||
var toAdd = Math.max(0, addAmount - curr.getValue() * 100);
|
||||
if (toAdd > 0) {
|
||||
if (IAuraType.forLevel(this.level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) && this.canGenerateRightNow(toAdd)) {
|
||||
this.generateAura(toAdd);
|
||||
|
@ -63,9 +63,9 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<BlockState, MutableInt> entry : this.consumedRecently.entrySet()) {
|
||||
for (var entry : this.consumedRecently.entrySet()) {
|
||||
if (entry.getKey() != state) {
|
||||
MutableInt val = entry.getValue();
|
||||
var val = entry.getValue();
|
||||
if (val.getValue() > 0)
|
||||
val.subtract(1);
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
|
||||
this.level.removeBlock(pos, false);
|
||||
|
||||
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
|
||||
var color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
|
||||
if (toAdd > 0) {
|
||||
for (int i = this.level.random.nextInt(5) + 5; i >= 0; i--)
|
||||
for (var i = this.level.random.nextInt(5) + 5; i >= 0; i--)
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
||||
pos.getX() + 0.25F + this.level.random.nextFloat() * 0.5F,
|
||||
pos.getY() + 0.25F + this.level.random.nextFloat() * 0.5F,
|
||||
|
@ -102,12 +102,12 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
super.writeNBT(compound, type);
|
||||
|
||||
if (type != SaveType.SYNC && !this.consumedRecently.isEmpty()) {
|
||||
ListTag list = new ListTag();
|
||||
for (Map.Entry<BlockState, MutableInt> entry : this.consumedRecently.entrySet()) {
|
||||
BlockState state = entry.getKey();
|
||||
Block block = state.getBlock();
|
||||
var list = new ListTag();
|
||||
for (var entry : this.consumedRecently.entrySet()) {
|
||||
var state = entry.getKey();
|
||||
var block = state.getBlock();
|
||||
|
||||
CompoundTag tag = new CompoundTag();
|
||||
var tag = new CompoundTag();
|
||||
tag.putString("block", block.getRegistryName().toString());
|
||||
tag.putInt("amount", entry.getValue().intValue());
|
||||
list.add(tag);
|
||||
|
@ -121,10 +121,10 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
super.readNBT(compound, type);
|
||||
if (type != SaveType.SYNC) {
|
||||
this.consumedRecently.clear();
|
||||
ListTag list = compound.getList("consumed_recently", 10);
|
||||
for (Tag base : list) {
|
||||
CompoundTag tag = (CompoundTag) base;
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
|
||||
var list = compound.getList("consumed_recently", 10);
|
||||
for (var base : list) {
|
||||
var tag = (CompoundTag) base;
|
||||
var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
|
||||
if (block != null)
|
||||
this.consumedRecently.put(block.defaultBlockState(), new MutableInt(tag.getInt("amount")));
|
||||
}
|
|
@ -56,14 +56,14 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
|||
@Override
|
||||
public void tick() {
|
||||
if (!this.level.isClientSide && this.level.getGameTime() % 5 == 0) {
|
||||
boolean did = false;
|
||||
var did = false;
|
||||
|
||||
Direction facing = this.level.getBlockState(this.worldPosition).getValue(BlockFurnaceHeater.FACING);
|
||||
BlockPos tilePos = this.worldPosition.relative(facing.getOpposite());
|
||||
BlockEntity tile = this.level.getBlockEntity(tilePos);
|
||||
var facing = this.level.getBlockState(this.worldPosition).getValue(BlockFurnaceHeater.FACING);
|
||||
var tilePos = this.worldPosition.relative(facing.getOpposite());
|
||||
var tile = this.level.getBlockEntity(tilePos);
|
||||
if (tile instanceof AbstractFurnaceBlockEntity furnace && this.isReady(furnace)) {
|
||||
ContainerData data = getFurnaceData(furnace);
|
||||
int burnTime = data.get(0);
|
||||
var data = getFurnaceData(furnace);
|
||||
var burnTime = data.get(0);
|
||||
if (burnTime <= 0)
|
||||
this.level.setBlockAndUpdate(tilePos, this.level.getBlockState(tilePos).setValue(AbstractFurnaceBlock.LIT, true));
|
||||
|
||||
|
@ -71,8 +71,8 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
|||
//if set higher than 199, it'll never finish because the furnace does ++ and then ==
|
||||
data.set(2, Math.min(data.get(3) - 1, data.get(2) + 5));
|
||||
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition);
|
||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition);
|
||||
var chunk = IAuraChunk.getAuraChunk(this.level, spot);
|
||||
chunk.drainAura(spot, Mth.ceil((200 - burnTime) * 16.6F));
|
||||
did = true;
|
||||
|
||||
|
@ -100,13 +100,13 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
|||
if (!furnace.getItem(1).isEmpty())
|
||||
return false;
|
||||
|
||||
ItemStack input = furnace.getItem(0);
|
||||
var input = furnace.getItem(0);
|
||||
if (!input.isEmpty()) {
|
||||
AbstractCookingRecipe recipe = this.level.getRecipeManager().getRecipeFor(getRecipeType(furnace), furnace, this.level).orElse(null);
|
||||
var recipe = this.level.getRecipeManager().getRecipeFor(getRecipeType(furnace), furnace, this.level).orElse(null);
|
||||
if (recipe == null)
|
||||
return false;
|
||||
ItemStack output = recipe.getResultItem();
|
||||
ItemStack currOutput = furnace.getItem(2);
|
||||
var output = recipe.getResultItem();
|
||||
var currOutput = furnace.getItem(2);
|
||||
return currOutput.isEmpty() || Helper.areItemsEqual(currOutput, output, true) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize();
|
||||
} else
|
||||
return false;
|
||||
|
|
|
@ -45,22 +45,22 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
if (this.redstonePower > 0)
|
||||
return;
|
||||
|
||||
ItemStack curr = this.items.getStackInSlot(0);
|
||||
var curr = this.items.getStackInSlot(0);
|
||||
push:
|
||||
if (!curr.isEmpty()) {
|
||||
BlockState state = this.level.getBlockState(this.worldPosition);
|
||||
Direction facing = state.getValue(BlockGratedChute.FACING);
|
||||
BlockEntity tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
var state = this.level.getBlockState(this.worldPosition);
|
||||
var facing = state.getValue(BlockGratedChute.FACING);
|
||||
var tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
if (tile == null)
|
||||
break push;
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
||||
var handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
||||
facing.getOpposite()).orElse(null);
|
||||
if (handler == null)
|
||||
break push;
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack theoreticalDrain = this.items.extractItem(0, 1, true);
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var theoreticalDrain = this.items.extractItem(0, 1, true);
|
||||
if (!theoreticalDrain.isEmpty()) {
|
||||
ItemStack left = handler.insertItem(i, theoreticalDrain, false);
|
||||
var left = handler.insertItem(i, theoreticalDrain, false);
|
||||
if (left.isEmpty()) {
|
||||
this.items.extractItem(0, 1, false);
|
||||
break push;
|
||||
|
@ -70,16 +70,16 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
pull:
|
||||
if (curr.isEmpty() || curr.getCount() < curr.getMaxStackSize()) {
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(
|
||||
this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(),
|
||||
this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1));
|
||||
for (ItemEntity item : items) {
|
||||
for (var item : items) {
|
||||
if (!item.isAlive())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
ItemStack left = this.items.insertItem(0, stack, false);
|
||||
var left = this.items.insertItem(0, stack, false);
|
||||
if (!ItemStack.isSame(stack, left)) {
|
||||
if (left.isEmpty()) {
|
||||
item.kill();
|
||||
|
@ -90,16 +90,16 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
BlockEntity tileUp = this.level.getBlockEntity(this.worldPosition.above());
|
||||
var tileUp = this.level.getBlockEntity(this.worldPosition.above());
|
||||
if (tileUp == null)
|
||||
break pull;
|
||||
IItemHandler handlerUp = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
|
||||
var handlerUp = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
|
||||
if (handlerUp == null)
|
||||
break pull;
|
||||
for (int i = 0; i < handlerUp.getSlots(); i++) {
|
||||
ItemStack theoreticalDrain = handlerUp.extractItem(i, 1, true);
|
||||
for (var i = 0; i < handlerUp.getSlots(); i++) {
|
||||
var theoreticalDrain = handlerUp.extractItem(i, 1, true);
|
||||
if (!theoreticalDrain.isEmpty()) {
|
||||
ItemStack left = this.items.insertItem(0, theoreticalDrain, false);
|
||||
var left = this.items.insertItem(0, theoreticalDrain, false);
|
||||
if (left.isEmpty()) {
|
||||
handlerUp.extractItem(i, 1, false);
|
||||
break pull;
|
||||
|
@ -113,11 +113,11 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
|
||||
private boolean isItemInFrame(ItemStack stack) {
|
||||
List<ItemFrame> frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
var frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
if (frames.isEmpty())
|
||||
return false;
|
||||
for (ItemFrame frame : frames) {
|
||||
ItemStack frameStack = frame.getItem();
|
||||
for (var frame : frames) {
|
||||
var frameStack = frame.getItem();
|
||||
if (Helper.areItemsEqual(stack, frameStack, true)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,26 +36,26 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab
|
|||
if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) {
|
||||
if (IAuraChunk.getAuraInArea(this.level, this.worldPosition, 25) < 100000)
|
||||
return;
|
||||
BlockEntity tile = this.level.getBlockEntity(this.worldPosition.below());
|
||||
var tile = this.level.getBlockEntity(this.worldPosition.below());
|
||||
if (!isValidHopper(tile))
|
||||
return;
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
var handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(7));
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(7));
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
for (ItemEntity item : items) {
|
||||
for (var item : items) {
|
||||
if (!item.isAlive() || item.hasPickUpDelay())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
ItemStack copy = stack.copy();
|
||||
var copy = stack.copy();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
copy = handler.insertItem(i, copy, false);
|
||||
if (copy.isEmpty()) {
|
||||
break;
|
||||
|
@ -67,7 +67,7 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab
|
|||
if (copy.isEmpty())
|
||||
item.kill();
|
||||
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 25, this.worldPosition);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 25, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 500);
|
||||
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
|
@ -65,7 +65,7 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
@Override
|
||||
public final ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
return ClientboundBlockEntityDataPacket.create(this, e -> {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
var compound = new CompoundTag();
|
||||
this.writeNBT(compound, SaveType.SYNC);
|
||||
return compound;
|
||||
});
|
||||
|
@ -73,7 +73,7 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
|
||||
@Override
|
||||
public final CompoundTag getUpdateTag() {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
var compound = new CompoundTag();
|
||||
this.writeNBT(compound, SaveType.SYNC);
|
||||
return compound;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
public void sendToClients() {
|
||||
var world = (ServerLevel) this.getLevel();
|
||||
var entities = world.getChunkSource().chunkMap.getPlayers(new ChunkPos(this.getBlockPos()), false);
|
||||
ClientboundBlockEntityDataPacket packet = this.getUpdatePacket();
|
||||
var packet = this.getUpdatePacket();
|
||||
for (var e : entities)
|
||||
e.connection.send(packet);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
return this.itemHandler.cast();
|
||||
} else if (capability == NaturesAuraAPI.capAuraContainer) {
|
||||
if (this.auraContainer == null) {
|
||||
IAuraContainer container = this.getAuraContainer();
|
||||
var container = this.getAuraContainer();
|
||||
this.auraContainer = container == null ? LazyOptional.empty() : LazyOptional.of(() -> container);
|
||||
}
|
||||
return this.auraContainer.cast();
|
||||
|
@ -137,10 +137,10 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
public void dropInventory() {
|
||||
IItemHandler handler = this.getItemHandler();
|
||||
if (handler != null) {
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack stack = handler.getStackInSlot(i);
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var stack = handler.getStackInSlot(i);
|
||||
if (!stack.isEmpty()) {
|
||||
ItemEntity item = new ItemEntity(this.level, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, stack);
|
||||
var item = new ItemEntity(this.level, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, stack);
|
||||
this.level.addFreshEntity(item);
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
}
|
||||
|
||||
public void modifyDrop(ItemStack regularItem) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
var compound = new CompoundTag();
|
||||
this.writeNBT(compound, SaveType.BLOCK);
|
||||
if (!compound.isEmpty()) {
|
||||
if (!regularItem.hasTag()) regularItem.setTag(new CompoundTag());
|
||||
|
@ -158,18 +158,18 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
|
||||
public void loadDataOnPlace(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundTag compound = stack.getTag().getCompound("data");
|
||||
var compound = stack.getTag().getCompound("data");
|
||||
if (compound != null) this.readNBT(compound, SaveType.BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canGenerateRightNow(int toAdd) {
|
||||
if (this.wantsLimitRemover()) {
|
||||
BlockState below = this.level.getBlockState(this.worldPosition.below());
|
||||
var below = this.level.getBlockState(this.worldPosition.below());
|
||||
if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER)
|
||||
return true;
|
||||
}
|
||||
int aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 35);
|
||||
var aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 35);
|
||||
return aura + toAdd <= IAuraChunk.DEFAULT_AURA * 2;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
|
||||
public void generateAura(int amount) {
|
||||
while (amount > 0) {
|
||||
BlockPos spot = IAuraChunk.getLowestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var spot = IAuraChunk.getLowestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
amount -= IAuraChunk.getAuraChunk(this.level, spot).storeAura(spot, amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,18 +32,18 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
|||
}
|
||||
this.cooldown = 1;
|
||||
|
||||
IItemHandler above = this.getHandler(Direction.UP);
|
||||
var above = this.getHandler(Direction.UP);
|
||||
if (above == null)
|
||||
return;
|
||||
IItemHandler dest = this.getNextSide();
|
||||
var dest = this.getNextSide();
|
||||
if (dest == null)
|
||||
return;
|
||||
for (int i = 0; i < above.getSlots(); i++) {
|
||||
ItemStack stack = above.extractItem(i, 1, true);
|
||||
for (var i = 0; i < above.getSlots(); i++) {
|
||||
var stack = above.extractItem(i, 1, true);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
for (int j = 0; j < dest.getSlots(); j++) {
|
||||
ItemStack remain = dest.insertItem(j, stack, false);
|
||||
for (var j = 0; j < dest.getSlots(); j++) {
|
||||
var remain = dest.insertItem(j, stack, false);
|
||||
if (!ItemStack.isSame(remain, stack)) {
|
||||
above.extractItem(i, 1, false);
|
||||
this.cooldown = 3;
|
||||
|
@ -54,8 +54,8 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
|||
}
|
||||
|
||||
private IItemHandler getHandler(Direction direction) {
|
||||
BlockPos offset = this.worldPosition.relative(direction);
|
||||
BlockEntity tile = this.level.getBlockEntity(offset);
|
||||
var offset = this.worldPosition.relative(direction);
|
||||
var tile = this.level.getBlockEntity(offset);
|
||||
if (tile == null)
|
||||
return null;
|
||||
return tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).orElse(null);
|
||||
|
@ -64,8 +64,8 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
|||
private IItemHandler getNextSide() {
|
||||
if (this.isRandomMode) {
|
||||
List<IItemHandler> handlers = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
IItemHandler handler = this.getHandler(Direction.values()[i]);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var handler = this.getHandler(Direction.values()[i]);
|
||||
if (handler != null)
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
|||
return null;
|
||||
return handlers.get(this.level.random.nextInt(handlers.size()));
|
||||
} else {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
this.currentSide = this.currentSide.getClockWise();
|
||||
IItemHandler handler = this.getHandler(this.currentSide);
|
||||
var handler = this.getHandler(this.currentSide);
|
||||
if (handler != null)
|
||||
return handler;
|
||||
}
|
|
@ -23,16 +23,16 @@ public class BlockEntityMossGenerator extends BlockEntityImpl implements ITickab
|
|||
if (!this.level.isClientSide) {
|
||||
if (this.level.getGameTime() % 20 != 0)
|
||||
return;
|
||||
LevelData data = (LevelData) ILevelData.getLevelData(this.level);
|
||||
var data = (LevelData) ILevelData.getLevelData(this.level);
|
||||
|
||||
List<BlockPos> possibleOffsets = new ArrayList<>();
|
||||
int range = 2;
|
||||
for (int x = -range; x <= range; x++)
|
||||
for (int y = -range; y <= range; y++)
|
||||
for (int z = -range; z <= range; z++) {
|
||||
BlockPos offset = this.worldPosition.offset(x, y, z);
|
||||
boolean isRecent = data.recentlyConvertedMossStones.contains(offset);
|
||||
BlockState state = this.level.getBlockState(offset);
|
||||
var range = 2;
|
||||
for (var x = -range; x <= range; x++)
|
||||
for (var y = -range; y <= range; y++)
|
||||
for (var z = -range; z <= range; z++) {
|
||||
var offset = this.worldPosition.offset(x, y, z);
|
||||
var isRecent = data.recentlyConvertedMossStones.contains(offset);
|
||||
var state = this.level.getBlockState(offset);
|
||||
if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().containsKey(state)) {
|
||||
if (isRecent)
|
||||
continue;
|
||||
|
@ -44,11 +44,11 @@ public class BlockEntityMossGenerator extends BlockEntityImpl implements ITickab
|
|||
|
||||
if (possibleOffsets.isEmpty())
|
||||
return;
|
||||
BlockPos offset = possibleOffsets.get(this.level.random.nextInt(possibleOffsets.size()));
|
||||
BlockState state = this.level.getBlockState(offset);
|
||||
BlockState result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().get(state);
|
||||
var offset = possibleOffsets.get(this.level.random.nextInt(possibleOffsets.size()));
|
||||
var state = this.level.getBlockState(offset);
|
||||
var result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().get(state);
|
||||
|
||||
int toAdd = 7000;
|
||||
var toAdd = 7000;
|
||||
if (this.canGenerateRightNow(toAdd)) {
|
||||
this.generateAura(toAdd);
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
|
|
|
@ -25,8 +25,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
||||
|
@ -49,7 +47,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
|
||||
@Override
|
||||
protected boolean canExtract(ItemStack stack, int slot, int amount) {
|
||||
IAuraContainer cap = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
var cap = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (cap != null)
|
||||
return cap.storeAura(1, true) <= 0;
|
||||
else
|
||||
|
@ -72,14 +70,14 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
Random rand = this.level.random;
|
||||
var rand = this.level.random;
|
||||
|
||||
if (this.level.getGameTime() % 40 == 0) {
|
||||
int index = 0;
|
||||
for (int x = -2; x <= 2; x += 4) {
|
||||
for (int z = -2; z <= 2; z += 4) {
|
||||
BlockPos offset = this.worldPosition.offset(x, 1, z);
|
||||
BlockState state = this.level.getBlockState(offset);
|
||||
var index = 0;
|
||||
for (var x = -2; x <= 2; x += 4) {
|
||||
for (var z = -2; z <= 2; z += 4) {
|
||||
var offset = this.worldPosition.offset(x, 1, z);
|
||||
var state = this.level.getBlockState(offset);
|
||||
this.catalysts[index] = state.getBlock().getCloneItemStack(this.level, offset, state);
|
||||
index++;
|
||||
}
|
||||
|
@ -88,7 +86,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
|
||||
if (!this.level.isClientSide) {
|
||||
if (this.level.getGameTime() % 40 == 0 || this.firstTick) {
|
||||
StructureState newState = this.getNewState();
|
||||
var newState = this.getNewState();
|
||||
if (newState != this.structureState) {
|
||||
this.structureState = newState;
|
||||
this.sendToClients();
|
||||
|
@ -97,13 +95,13 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
|
||||
if (this.structureState != StructureState.INVALID) {
|
||||
int space = this.container.storeAura(300, true);
|
||||
var space = this.container.storeAura(300, true);
|
||||
IAuraType expectedType = this.structureState == StructureState.NETHER ? NaturesAuraAPI.TYPE_NETHER : NaturesAuraAPI.TYPE_OVERWORLD;
|
||||
if (space > 0 && IAuraType.forLevel(this.level).isSimilar(expectedType)) {
|
||||
int toStore = Math.min(IAuraChunk.getAuraInArea(this.level, this.worldPosition, 20), space);
|
||||
var toStore = Math.min(IAuraChunk.getAuraInArea(this.level, this.worldPosition, 20), space);
|
||||
if (toStore > 0) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition);
|
||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition);
|
||||
var chunk = IAuraChunk.getAuraChunk(this.level, spot);
|
||||
|
||||
chunk.drainAura(spot, toStore);
|
||||
this.container.storeAura(toStore, false);
|
||||
|
@ -114,17 +112,17 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
this.worldPosition.getY() + rand.nextFloat() * 10F,
|
||||
this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F,
|
||||
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F,
|
||||
rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() * 1F + 1F
|
||||
rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() + 1F
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = this.items.getStackInSlot(0);
|
||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
var stack = this.items.getStackInSlot(0);
|
||||
var container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (!stack.isEmpty() && container != null) {
|
||||
int theoreticalDrain = this.container.drainAura(1000, true);
|
||||
var theoreticalDrain = this.container.drainAura(1000, true);
|
||||
if (theoreticalDrain > 0) {
|
||||
int stored = container.storeAura(theoreticalDrain, false);
|
||||
var stored = container.storeAura(theoreticalDrain, false);
|
||||
if (stored > 0) {
|
||||
this.container.drainAura(stored, false);
|
||||
|
||||
|
@ -142,7 +140,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
this.currentRecipe = null;
|
||||
this.timer = 0;
|
||||
} else {
|
||||
int req = Mth.ceil(this.currentRecipe.aura / (double) this.currentRecipe.time);
|
||||
var req = Mth.ceil(this.currentRecipe.aura / (double) this.currentRecipe.time);
|
||||
if (this.container.getStoredAura() >= req) {
|
||||
this.container.drainAura(req, false);
|
||||
|
||||
|
@ -170,7 +168,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
} else {
|
||||
if (this.structureState != StructureState.INVALID) {
|
||||
if (rand.nextFloat() >= 0.7F) {
|
||||
int fourths = this.container.getMaxAura() / 4;
|
||||
var fourths = this.container.getMaxAura() / 4;
|
||||
if (this.container.getStoredAura() > 0) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(),
|
||||
|
@ -200,12 +198,12 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
|
||||
private AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
IAuraType type = IAuraType.forLevel(this.level);
|
||||
for (AltarRecipe recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, null)) {
|
||||
var type = IAuraType.forLevel(this.level);
|
||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, null)) {
|
||||
if (recipe.input.test(input) && (recipe.requiredType == null || type.isSimilar(recipe.requiredType))) {
|
||||
if (recipe.catalyst == Ingredient.EMPTY)
|
||||
return recipe;
|
||||
for (ItemStack stack : this.catalysts)
|
||||
for (var stack : this.catalysts)
|
||||
if (recipe.catalyst.test(stack))
|
||||
return recipe;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ public class BlockEntityOakGenerator extends BlockEntityImpl implements ITickabl
|
|||
public void tick() {
|
||||
if (!this.level.isClientSide)
|
||||
while (!this.scheduledBigTrees.isEmpty()) {
|
||||
BlockPos pos = this.scheduledBigTrees.remove();
|
||||
var pos = this.scheduledBigTrees.remove();
|
||||
if (this.level.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) {
|
||||
int toAdd = 100000;
|
||||
boolean canGen = this.canGenerateRightNow(toAdd);
|
||||
var toAdd = 100000;
|
||||
var canGen = this.canGenerateRightNow(toAdd);
|
||||
if (canGen)
|
||||
this.generateAura(toAdd);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
}
|
||||
|
||||
private OfferingRecipe getRecipe(ItemStack input) {
|
||||
for (OfferingRecipe recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.OFFERING_TYPE, null, null))
|
||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.OFFERING_TYPE, null, null))
|
||||
if (recipe.input.test(input))
|
||||
return recipe;
|
||||
return null;
|
||||
|
@ -54,44 +54,44 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
if (!Multiblocks.OFFERING_TABLE.isComplete(this.level, this.worldPosition))
|
||||
return;
|
||||
|
||||
ItemStack stack = this.items.getStackInSlot(0);
|
||||
var stack = this.items.getStackInSlot(0);
|
||||
if (stack.isEmpty())
|
||||
return;
|
||||
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(1));
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(1));
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
OfferingRecipe recipe = this.getRecipe(stack);
|
||||
var recipe = this.getRecipe(stack);
|
||||
if (recipe == null)
|
||||
return;
|
||||
|
||||
for (ItemEntity item : items) {
|
||||
for (var item : items) {
|
||||
if (!item.isAlive() || item.hasPickUpDelay())
|
||||
continue;
|
||||
|
||||
ItemStack itemStack = item.getItem();
|
||||
var itemStack = item.getItem();
|
||||
if (itemStack.isEmpty() || itemStack.getCount() != 1)
|
||||
continue;
|
||||
|
||||
if (!recipe.startItem.test(itemStack))
|
||||
continue;
|
||||
|
||||
int amount = Helper.getIngredientAmount(recipe.input);
|
||||
int recipeCount = stack.getCount() / amount;
|
||||
var amount = Helper.getIngredientAmount(recipe.input);
|
||||
var recipeCount = stack.getCount() / amount;
|
||||
stack.shrink(recipeCount * amount);
|
||||
item.kill();
|
||||
this.sendToClients();
|
||||
|
||||
for (int i = 0; i < recipeCount; i++)
|
||||
for (var i = 0; i < recipeCount; i++)
|
||||
this.itemsToSpawn.add(recipe.output.copy());
|
||||
|
||||
if (Multiblocks.OFFERING_TABLE.forEach(this.worldPosition, 'R', (pos, m) -> this.level.getBlockState(pos).getBlock() == Blocks.WITHER_ROSE)) {
|
||||
for (int i = this.level.random.nextInt(5) + 3; i >= 0; i--)
|
||||
for (var i = this.level.random.nextInt(5) + 3; i >= 0; i--)
|
||||
this.itemsToSpawn.add(new ItemStack(Items.BLACK_DYE));
|
||||
}
|
||||
|
||||
LightningBolt lightningboltentity = EntityType.LIGHTNING_BOLT.create(this.level);
|
||||
var lightningboltentity = EntityType.LIGHTNING_BOLT.create(this.level);
|
||||
lightningboltentity.setVisualOnly(true);
|
||||
lightningboltentity.moveTo(Vec3.atCenterOf(this.worldPosition));
|
||||
this.level.addFreshEntity(lightningboltentity);
|
||||
|
@ -115,8 +115,8 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
compound.put("items", this.items.serializeNBT());
|
||||
|
||||
if (type != SaveType.SYNC) {
|
||||
ListTag list = new ListTag();
|
||||
for (ItemStack stack : this.itemsToSpawn)
|
||||
var list = new ListTag();
|
||||
for (var stack : this.itemsToSpawn)
|
||||
list.add(stack.serializeNBT());
|
||||
compound.put("items_to_spawn", list);
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
|
||||
if (type != SaveType.SYNC) {
|
||||
this.itemsToSpawn.clear();
|
||||
ListTag list = compound.getList("items_to_spawn", 10);
|
||||
for (Tag base : list)
|
||||
var list = compound.getList("items_to_spawn", 10);
|
||||
for (var base : list)
|
||||
this.itemsToSpawn.add(ItemStack.of((CompoundTag) base));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,45 +37,45 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock
|
|||
if (!this.level.isClientSide && this.level.getGameTime() % 15 == 0) {
|
||||
if (this.redstonePower > 0)
|
||||
return;
|
||||
BlockEntity tileUp = this.level.getBlockEntity(this.worldPosition.above());
|
||||
var tileUp = this.level.getBlockEntity(this.worldPosition.above());
|
||||
if (tileUp == null)
|
||||
return;
|
||||
IItemHandler handler = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
|
||||
var handler = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
|
||||
if (handler == null)
|
||||
return;
|
||||
List<ItemFrame> frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
var frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
if (frames.isEmpty())
|
||||
return;
|
||||
|
||||
List<BlockPos> validPositions = new ArrayList<>();
|
||||
int range = 5;
|
||||
for (int x = -range; x <= range; x++)
|
||||
for (int y = -range; y <= range; y++)
|
||||
for (int z = -range; z <= range; z++) {
|
||||
BlockPos pos = this.worldPosition.offset(x, y, z);
|
||||
var range = 5;
|
||||
for (var x = -range; x <= range; x++)
|
||||
for (var y = -range; y <= range; y++)
|
||||
for (var z = -range; z <= range; z++) {
|
||||
var pos = this.worldPosition.offset(x, y, z);
|
||||
if (!this.framesContain(frames, pos, this.level.getBlockState(pos)))
|
||||
continue;
|
||||
|
||||
BlockPos up = pos.above();
|
||||
BlockState state = this.level.getBlockState(up);
|
||||
var up = pos.above();
|
||||
var state = this.level.getBlockState(up);
|
||||
if (state.getMaterial().isReplaceable())
|
||||
validPositions.add(up);
|
||||
}
|
||||
if (validPositions.isEmpty())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack stack = handler.extractItem(i, 1, true);
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var stack = handler.extractItem(i, 1, true);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
|
||||
BlockPos pos = validPositions.get(this.level.random.nextInt(validPositions.size()));
|
||||
ItemStack left = this.tryPlace(stack.copy(), pos);
|
||||
var pos = validPositions.get(this.level.random.nextInt(validPositions.size()));
|
||||
var left = this.tryPlace(stack.copy(), pos);
|
||||
if (ItemStack.isSame(stack, left))
|
||||
continue;
|
||||
|
||||
handler.extractItem(i, 1, false);
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 10, this.worldPosition);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 10, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 1000);
|
||||
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.PLACER_PLACING));
|
||||
|
@ -86,12 +86,12 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock
|
|||
}
|
||||
|
||||
private boolean framesContain(List<ItemFrame> frames, BlockPos pos, BlockState state) {
|
||||
ItemStack stack = state.getBlock().getCloneItemStack(this.level, pos, state);
|
||||
var stack = state.getBlock().getCloneItemStack(this.level, pos, state);
|
||||
if (stack.isEmpty())
|
||||
return false;
|
||||
|
||||
for (ItemFrame frame : frames) {
|
||||
ItemStack frameStack = frame.getItem();
|
||||
for (var frame : frames) {
|
||||
var frameStack = frame.getItem();
|
||||
if (frameStack.isEmpty())
|
||||
continue;
|
||||
if (Helper.areItemsEqual(stack, frameStack, false))
|
||||
|
@ -106,9 +106,9 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock
|
|||
private ItemStack tryPlace(ItemStack stack, BlockPos pos) {
|
||||
if (!(this.level instanceof ServerLevel))
|
||||
return stack;
|
||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
||||
var fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
||||
fake.getInventory().items.set(fake.getInventory().selected, stack);
|
||||
BlockHitResult ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false);
|
||||
var ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false);
|
||||
ForgeHooks.onPlaceItemIntoWorld(new UseOnContext(fake, InteractionHand.MAIN_HAND, ray));
|
||||
return fake.getMainHandItem().copy();
|
||||
}
|
||||
|
|
|
@ -24,26 +24,26 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
|||
public void tick() {
|
||||
if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) {
|
||||
if (Multiblocks.POTION_GENERATOR.isComplete(this.level, this.worldPosition)) {
|
||||
boolean addedOne = false;
|
||||
var addedOne = false;
|
||||
|
||||
List<AreaEffectCloud> clouds = this.level.getEntitiesOfClass(AreaEffectCloud.class, new AABB(this.worldPosition).inflate(2));
|
||||
for (AreaEffectCloud cloud : clouds) {
|
||||
var clouds = this.level.getEntitiesOfClass(AreaEffectCloud.class, new AABB(this.worldPosition).inflate(2));
|
||||
for (var cloud : clouds) {
|
||||
if (!cloud.isAlive())
|
||||
continue;
|
||||
|
||||
if (!addedOne) {
|
||||
Potion type = cloud.getPotion();
|
||||
var type = cloud.getPotion();
|
||||
if (type == null)
|
||||
continue;
|
||||
|
||||
for (MobEffectInstance effect : type.getEffects()) {
|
||||
MobEffect potion = effect.getEffect();
|
||||
for (var effect : type.getEffects()) {
|
||||
var potion = effect.getEffect();
|
||||
if (!potion.isBeneficial() || potion.isInstantenous()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int toAdd = (effect.getAmplifier() * 7 + 1) * (effect.getDuration() / 25) * 100;
|
||||
boolean canGen = this.canGenerateRightNow(toAdd);
|
||||
var toAdd = (effect.getAmplifier() * 7 + 1) * (effect.getDuration() / 25) * 100;
|
||||
var canGen = this.canGenerateRightNow(toAdd);
|
||||
if (canGen)
|
||||
this.generateAura(toAdd);
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
|||
}
|
||||
}
|
||||
|
||||
float newRadius = cloud.getRadius() - 0.25F;
|
||||
var newRadius = cloud.getRadius() - 0.25F;
|
||||
if (newRadius < 0.5F) {
|
||||
cloud.kill();
|
||||
} else {
|
||||
|
|
|
@ -23,22 +23,22 @@ public class BlockEntityPowderPlacer extends BlockEntityImpl {
|
|||
@Override
|
||||
public void onRedstonePowerChange(int newPower) {
|
||||
if (this.redstonePower <= 0 && newPower > 0) {
|
||||
List<EntityEffectInhibitor> powders = this.level.getEntitiesOfClass(EntityEffectInhibitor.class, new AABB(this.worldPosition, this.worldPosition.offset(1, 2, 1)), Entity::isAlive);
|
||||
for (Direction facing : Direction.values()) {
|
||||
var powders = this.level.getEntitiesOfClass(EntityEffectInhibitor.class, new AABB(this.worldPosition, this.worldPosition.offset(1, 2, 1)), Entity::isAlive);
|
||||
for (var facing : Direction.values()) {
|
||||
if (!facing.getAxis().isHorizontal())
|
||||
continue;
|
||||
BlockEntity tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
var tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
if (tile == null)
|
||||
continue;
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
var handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
if (handler == null)
|
||||
continue;
|
||||
|
||||
if (!powders.isEmpty()) {
|
||||
for (EntityEffectInhibitor powder : powders) {
|
||||
ItemStack drop = powder.getDrop();
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack remain = handler.insertItem(i, drop, false);
|
||||
for (var powder : powders) {
|
||||
var drop = powder.getDrop();
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var remain = handler.insertItem(i, drop, false);
|
||||
if (remain.isEmpty()) {
|
||||
powder.kill();
|
||||
break;
|
||||
|
@ -48,8 +48,8 @@ public class BlockEntityPowderPlacer extends BlockEntityImpl {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack stack = handler.extractItem(i, Integer.MAX_VALUE, true);
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var stack = handler.extractItem(i, Integer.MAX_VALUE, true);
|
||||
if (stack.isEmpty() || stack.getItem() != ModItems.EFFECT_POWDER)
|
||||
continue;
|
||||
EntityEffectInhibitor.place(this.level, stack, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 1, this.worldPosition.getZ() + 0.5);
|
|
@ -49,24 +49,24 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
|
|||
this.lastEnergy = this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
for (Direction facing : Direction.values()) {
|
||||
BlockEntity tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
for (var facing : Direction.values()) {
|
||||
var tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
if (tile == null)
|
||||
continue;
|
||||
IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite()).orElse(null);
|
||||
var storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite()).orElse(null);
|
||||
if (storage == null)
|
||||
continue;
|
||||
int canStore = storage.receiveEnergy(Integer.MAX_VALUE, true);
|
||||
var canStore = storage.receiveEnergy(Integer.MAX_VALUE, true);
|
||||
if (canStore <= 0)
|
||||
continue;
|
||||
int extracted = this.storage.extractEnergy(canStore, false);
|
||||
var extracted = this.storage.extractEnergy(canStore, false);
|
||||
if (extracted <= 0)
|
||||
continue;
|
||||
storage.receiveEnergy(extracted, false);
|
||||
break;
|
||||
}
|
||||
|
||||
int emptyPart = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored();
|
||||
var emptyPart = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored();
|
||||
if (emptyPart <= 0)
|
||||
return;
|
||||
if (this.level.getGameTime() % 20 != 0)
|
||||
|
@ -74,14 +74,14 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
|
|||
if (!Multiblocks.RF_CONVERTER.isComplete(this.level, this.worldPosition))
|
||||
return;
|
||||
|
||||
int aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 45);
|
||||
var aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 45);
|
||||
if (aura <= IAuraChunk.DEFAULT_AURA)
|
||||
return;
|
||||
int amountToGen = Math.min(Math.min(10000, aura / 1000), emptyPart);
|
||||
int amountToUse = Mth.ceil(amountToGen / ModConfig.instance.auraToRFRatio.get());
|
||||
var amountToGen = Math.min(Math.min(10000, aura / 1000), emptyPart);
|
||||
var amountToUse = Mth.ceil(amountToGen / ModConfig.instance.auraToRFRatio.get());
|
||||
|
||||
this.storage.setEnergy(this.storage.getEnergyStored() + amountToGen);
|
||||
BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 45, this.worldPosition);
|
||||
var pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 45, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, amountToUse);
|
||||
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
|
@ -23,7 +23,7 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I
|
|||
if (this.level.isClientSide || this.level.getGameTime() % 10 != 0)
|
||||
return;
|
||||
if (this.generationTimer > 0) {
|
||||
int amount = this.amountToRelease * 10;
|
||||
var amount = this.amountToRelease * 10;
|
||||
if (this.canGenerateRightNow(amount)) {
|
||||
this.generateAura(amount);
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.SLIME_SPLIT_GEN_CREATE, this.color));
|
||||
|
@ -42,7 +42,7 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I
|
|||
}
|
||||
|
||||
public void startGenerating(Slime slime) {
|
||||
int size = slime.getSize();
|
||||
var size = slime.getSize();
|
||||
this.generationTimer = size * 30;
|
||||
this.amountToRelease = (size * this.getGenerationAmount(slime)) / this.generationTimer;
|
||||
this.color = this.getSlimeColor(slime);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
int range = this.getRange();
|
||||
var range = this.getRange();
|
||||
if (range <= 0)
|
||||
return;
|
||||
|
||||
|
@ -44,13 +44,13 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable
|
|||
if (this.level.getGameTime() % 10 != 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
double angle = this.level.random.nextFloat() * Math.PI * 2;
|
||||
BlockPos pos = this.worldPosition.offset(Math.cos(angle) * range * this.level.random.nextFloat(), 0, Math.sin(angle) * range * this.level.random.nextFloat());
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var angle = this.level.random.nextFloat() * Math.PI * 2;
|
||||
var pos = this.worldPosition.offset(Math.cos(angle) * range * this.level.random.nextFloat(), 0, Math.sin(angle) * range * this.level.random.nextFloat());
|
||||
pos = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
||||
BlockPos down = pos.below();
|
||||
var down = pos.below();
|
||||
|
||||
Fluid fluid = this.level.getFluidState(down).getType();
|
||||
var fluid = this.level.getFluidState(down).getType();
|
||||
if (fluid == Fluids.WATER) {
|
||||
if (this.level.getBlockState(down).getMaterial().isReplaceable())
|
||||
this.level.setBlockAndUpdate(down, Blocks.ICE.defaultBlockState());
|
||||
|
@ -67,7 +67,7 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable
|
|||
continue;
|
||||
}
|
||||
|
||||
BlockPos auraPos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition);
|
||||
var auraPos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, auraPos).drainAura(auraPos, 300);
|
||||
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
|
@ -77,9 +77,9 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable
|
|||
} else {
|
||||
if (this.level.getGameTime() % 30 != 0)
|
||||
return;
|
||||
for (int i = range * 4; i >= 0; i--) {
|
||||
double angle = this.level.random.nextFloat() * Math.PI * 2;
|
||||
BlockPos pos = this.worldPosition.offset(
|
||||
for (var i = range * 4; i >= 0; i--) {
|
||||
var angle = this.level.random.nextFloat() * Math.PI * 2;
|
||||
var pos = this.worldPosition.offset(
|
||||
Math.cos(angle) * range * this.level.random.nextFloat(),
|
||||
Mth.nextInt(this.level.random, range / 2, range),
|
||||
Math.sin(angle) * range * this.level.random.nextFloat());
|
|
@ -19,7 +19,7 @@ public class BlockEntitySpawnLamp extends BlockEntityImpl {
|
|||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (!this.level.isClientSide) {
|
||||
LevelData data = (LevelData) ILevelData.getLevelData(this.level);
|
||||
var data = (LevelData) ILevelData.getLevelData(this.level);
|
||||
data.spawnLamps.add(this);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class BlockEntitySpawnLamp extends BlockEntityImpl {
|
|||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
if (!this.level.isClientSide) {
|
||||
LevelData data = (LevelData) ILevelData.getLevelData(this.level);
|
||||
var data = (LevelData) ILevelData.getLevelData(this.level);
|
||||
data.spawnLamps.remove(this);
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
super.onLoad();
|
||||
if (!this.level.isClientSide) {
|
||||
// add a ticket to water crops
|
||||
AABB area = new AABB(this.worldPosition).inflate(5, 1, 5);
|
||||
var area = new AABB(this.worldPosition).inflate(5, 1, 5);
|
||||
this.waterTicket = FarmlandWaterManager.addAABBTicket(this.level, area);
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
return;
|
||||
|
||||
// fill cauldrons
|
||||
BlockPos up = this.worldPosition.above();
|
||||
BlockState upState = this.level.getBlockState(up);
|
||||
var up = this.worldPosition.above();
|
||||
var upState = this.level.getBlockState(up);
|
||||
if (upState.hasProperty(BlockStateProperties.LEVEL_CAULDRON)) {
|
||||
int level = upState.getValue(BlockStateProperties.LEVEL_CAULDRON);
|
||||
if (level < 3) {
|
||||
|
@ -72,12 +72,12 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
}
|
||||
|
||||
// wet sponges
|
||||
int spongeRadius = 2;
|
||||
for (int x = -spongeRadius; x <= spongeRadius; x++) {
|
||||
for (int y = -spongeRadius; y <= spongeRadius; y++) {
|
||||
for (int z = -spongeRadius; z <= spongeRadius; z++) {
|
||||
BlockPos pos = this.worldPosition.offset(x, y, z);
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
var spongeRadius = 2;
|
||||
for (var x = -spongeRadius; x <= spongeRadius; x++) {
|
||||
for (var y = -spongeRadius; y <= spongeRadius; y++) {
|
||||
for (var z = -spongeRadius; z <= spongeRadius; z++) {
|
||||
var pos = this.worldPosition.offset(x, y, z);
|
||||
var state = this.level.getBlockState(pos);
|
||||
if (state.getBlock() == Blocks.SPONGE) {
|
||||
this.level.setBlock(pos, Blocks.WET_SPONGE.defaultBlockState(), 2);
|
||||
this.level.levelEvent(2001, pos, Block.getId(Blocks.WATER.defaultBlockState()));
|
||||
|
@ -89,8 +89,8 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
}
|
||||
|
||||
// generate obsidian
|
||||
for (Direction dir : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos side = this.worldPosition.relative(dir);
|
||||
for (var dir : Direction.Plane.HORIZONTAL) {
|
||||
var side = this.worldPosition.relative(dir);
|
||||
if (this.isLava(side, true)) {
|
||||
this.level.setBlockAndUpdate(side, ForgeEventFactory.fireFluidPlaceBlockEvent(this.level, side, side, Blocks.OBSIDIAN.defaultBlockState()));
|
||||
this.level.levelEvent(1501, side, 0);
|
||||
|
@ -100,7 +100,7 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
}
|
||||
|
||||
// generate stone
|
||||
BlockPos twoUp = this.worldPosition.above(2);
|
||||
var twoUp = this.worldPosition.above(2);
|
||||
if (this.isLava(twoUp, false) && (this.level.getBlockState(up).isAir() || this.isLava(up, false))) {
|
||||
this.level.setBlockAndUpdate(up, ForgeEventFactory.fireFluidPlaceBlockEvent(this.level, up, twoUp, Blocks.STONE.defaultBlockState()));
|
||||
this.level.levelEvent(1501, up, 0);
|
||||
|
@ -109,9 +109,9 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
}
|
||||
|
||||
// generate cobblestone
|
||||
for (Direction dir : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos twoSide = this.worldPosition.relative(dir, 2);
|
||||
BlockPos side = this.worldPosition.relative(dir);
|
||||
for (var dir : Direction.Plane.HORIZONTAL) {
|
||||
var twoSide = this.worldPosition.relative(dir, 2);
|
||||
var side = this.worldPosition.relative(dir);
|
||||
if (this.isLava(twoSide, false) && (this.level.getBlockState(side).isAir() || this.isLava(side, false))) {
|
||||
this.level.setBlockAndUpdate(side, ForgeEventFactory.fireFluidPlaceBlockEvent(this.level, side, twoSide, Blocks.COBBLESTONE.defaultBlockState()));
|
||||
this.level.levelEvent(1501, side, 0);
|
||||
|
@ -130,13 +130,13 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
|
||||
public void consumeAura(int amount) {
|
||||
while (amount > 0) {
|
||||
BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
amount -= IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, amount);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLava(BlockPos offset, boolean source) {
|
||||
FluidState state = this.level.getFluidState(offset);
|
||||
var state = this.level.getFluidState(offset);
|
||||
return (!source || state.isSource()) && state.getType().is(FluidTags.LAVA);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, IFluidHandler.FluidAction action) {
|
||||
int drain = Math.min(maxDrain, 1000);
|
||||
var drain = Math.min(maxDrain, 1000);
|
||||
if (action.execute())
|
||||
BlockEntitySpring.this.consumeAura(Mth.ceil(drain / 2F));
|
||||
return new FluidStack(Fluids.WATER, drain);
|
||||
|
|
|
@ -34,15 +34,15 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable
|
|||
@Override
|
||||
public void tick() {
|
||||
if (!this.level.isClientSide) {
|
||||
List<ItemFrame> frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
for (ItemFrame frame : frames) {
|
||||
ItemStack frameStack = frame.getItem();
|
||||
var frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
for (var frame : frames) {
|
||||
var frameStack = frame.getItem();
|
||||
if (frameStack.isEmpty() || frameStack.getItem() != ModItems.CLOCK_HAND)
|
||||
continue;
|
||||
|
||||
if (this.goalTime > 0) {
|
||||
long current = this.level.getDayTime();
|
||||
long toAdd = Math.min(75, this.goalTime - current);
|
||||
var current = this.level.getDayTime();
|
||||
var toAdd = Math.min(75, this.goalTime - current);
|
||||
if (toAdd <= 0) {
|
||||
this.goalTime = 0;
|
||||
this.sendToClients();
|
||||
|
@ -50,11 +50,11 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
((ServerLevelData) this.level.getLevelData()).setDayTime(current + toAdd);
|
||||
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, (int) toAdd * 20);
|
||||
|
||||
if (this.level instanceof ServerLevel) {
|
||||
PlayerList list = this.level.getServer().getPlayerList();
|
||||
var list = this.level.getServer().getPlayerList();
|
||||
list.broadcastAll(new ClientboundSetTimePacket(
|
||||
this.level.getGameTime(), this.level.getDayTime(),
|
||||
this.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
||||
|
@ -65,17 +65,17 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable
|
|||
if (this.level.getGameTime() % 20 != 0)
|
||||
return;
|
||||
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(1), Entity::isAlive);
|
||||
for (ItemEntity item : items) {
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(this.worldPosition).inflate(1), Entity::isAlive);
|
||||
for (var item : items) {
|
||||
if (item.hasPickUpDelay())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (stack.isEmpty() || stack.getItem() != Items.CLOCK)
|
||||
continue;
|
||||
|
||||
int dayGoal = Mth.floor((frame.getRotation() / 8F) * 24000F) + 18000;
|
||||
long current = this.level.getDayTime();
|
||||
long toMove = (24000 - current % 24000 + dayGoal) % 24000;
|
||||
var dayGoal = Mth.floor((frame.getRotation() / 8F) * 24000F) + 18000;
|
||||
var current = this.level.getDayTime();
|
||||
var toMove = (24000 - current % 24000 + dayGoal) % 24000;
|
||||
this.goalTime = current + toMove;
|
||||
this.sendToClients();
|
||||
|
||||
|
@ -93,10 +93,10 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable
|
|||
this.sendToClients();
|
||||
}
|
||||
} else if (this.goalTime > 0 && this.level.random.nextFloat() >= 0.25F) {
|
||||
double angle = Math.toRadians(this.level.getDayTime() * 5F % 360);
|
||||
double x = this.worldPosition.getX() + 0.5 + Math.sin(angle) * 3F;
|
||||
double z = this.worldPosition.getZ() + 0.5 + Math.cos(angle) * 3F;
|
||||
int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926;
|
||||
var angle = Math.toRadians(this.level.getDayTime() * 5F % 360);
|
||||
var x = this.worldPosition.getX() + 0.5 + Math.sin(angle) * 3F;
|
||||
var z = this.worldPosition.getZ() + 0.5 + Math.cos(angle) * 3F;
|
||||
var color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926;
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
x, this.worldPosition.getY() + 0.1F, z,
|
||||
0F, 0.12F, 0F,
|
|
@ -34,11 +34,11 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
|||
return;
|
||||
if (this.processTime <= 0)
|
||||
return;
|
||||
int color = this.type == WeatherType.SUN ? 0xf5d742 : this.type == WeatherType.RAIN ? 0x4d5ae3 : 0x373247;
|
||||
for (int r = 0; r < 360; r += 20) {
|
||||
double xOff = Math.cos(Math.toRadians(r)) * 3F;
|
||||
double zOff = Math.sin(Math.toRadians(r)) * 3F;
|
||||
for (int i = this.level.random.nextInt(3); i > 0; i--) {
|
||||
var color = this.type == WeatherType.SUN ? 0xf5d742 : this.type == WeatherType.RAIN ? 0x4d5ae3 : 0x373247;
|
||||
for (var r = 0; r < 360; r += 20) {
|
||||
var xOff = Math.cos(Math.toRadians(r)) * 3F;
|
||||
var zOff = Math.sin(Math.toRadians(r)) * 3F;
|
||||
for (var i = this.level.random.nextInt(3); i > 0; i--) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
this.worldPosition.getX() + 0.5F + xOff,
|
||||
this.worldPosition.getY(),
|
||||
|
@ -54,15 +54,15 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
|||
|
||||
if (this.processTime > 0) {
|
||||
if (this.processTime % 20 == 0) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 30000 * this.itemAmount);
|
||||
}
|
||||
|
||||
this.processTime--;
|
||||
if (this.processTime <= 0) {
|
||||
this.sendToClients();
|
||||
int time = 6000 * this.itemAmount;
|
||||
ServerLevel server = (ServerLevel) this.level;
|
||||
var time = 6000 * this.itemAmount;
|
||||
var server = (ServerLevel) this.level;
|
||||
switch (this.type) {
|
||||
case SUN -> server.setWeatherParameters(time, 0, false, false);
|
||||
case RAIN -> server.setWeatherParameters(0, time, true, false);
|
||||
|
@ -72,7 +72,7 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
|||
} else {
|
||||
if (this.level.getGameTime() % 20 != 0)
|
||||
return;
|
||||
Pair<WeatherType, Integer> type = this.getNextWeatherType();
|
||||
var type = this.getNextWeatherType();
|
||||
if (type == null)
|
||||
return;
|
||||
this.type = type.getLeft();
|
||||
|
@ -104,13 +104,13 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
|||
}
|
||||
|
||||
private Pair<WeatherType, Integer> getNextWeatherType() {
|
||||
AABB area = new AABB(this.worldPosition).inflate(2);
|
||||
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class, area, Entity::isAlive);
|
||||
for (ItemEntity entity : items) {
|
||||
var area = new AABB(this.worldPosition).inflate(2);
|
||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, area, Entity::isAlive);
|
||||
for (var entity : items) {
|
||||
if (entity.hasPickUpDelay())
|
||||
continue;
|
||||
ItemStack stack = entity.getItem();
|
||||
for (Map.Entry<ItemStack, WeatherType> entry : NaturesAuraAPI.WEATHER_CHANGER_CONVERSIONS.entrySet()) {
|
||||
var stack = entity.getItem();
|
||||
for (var entry : NaturesAuraAPI.WEATHER_CHANGER_CONVERSIONS.entrySet()) {
|
||||
if (!Helper.areItemsEqual(stack, entry.getKey(), true))
|
||||
continue;
|
||||
entity.setItem(ItemStack.EMPTY);
|
|
@ -54,13 +54,13 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
if (this.ritualPos != null && this.recipe != null) {
|
||||
if (this.level.getGameTime() % 5 == 0) {
|
||||
if (this.isRitualOkay()) {
|
||||
boolean wasOverHalf = this.timer >= this.recipe.time / 2;
|
||||
var wasOverHalf = this.timer >= this.recipe.time / 2;
|
||||
this.timer += 5;
|
||||
boolean isOverHalf = this.timer >= this.recipe.time / 2;
|
||||
var isOverHalf = this.timer >= this.recipe.time / 2;
|
||||
|
||||
if (!isOverHalf)
|
||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
BlockEntity tile = this.level.getBlockEntity(pos);
|
||||
var tile = this.level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityWoodStand && !((BlockEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
||||
(float) pos.getX() + 0.2F + this.level.random.nextFloat() * 0.6F,
|
||||
|
@ -83,7 +83,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
});
|
||||
recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false);
|
||||
|
||||
ItemEntity item = new ItemEntity(this.level,
|
||||
var item = new ItemEntity(this.level,
|
||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||
this.recipe.result.copy());
|
||||
this.level.addFreshEntity(item);
|
||||
|
@ -98,7 +98,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
this.timer = 0;
|
||||
} else if (isOverHalf && !wasOverHalf) {
|
||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
BlockEntity tile = this.level.getBlockEntity(pos);
|
||||
var tile = this.level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityWoodStand stand && !stand.items.getStackInSlot(0).isEmpty()) {
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
new PacketParticles(stand.worldPosition.getX(), stand.worldPosition.getY(), stand.worldPosition.getZ(), PacketParticles.Type.TR_CONSUME_ITEM));
|
||||
|
@ -129,11 +129,11 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
return;
|
||||
}
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
BlockPos offset = pos.offset(x, y, z);
|
||||
BlockState state = level.getBlockState(offset);
|
||||
for (var x = -1; x <= 1; x++) {
|
||||
for (var y = -1; y <= 1; y++) {
|
||||
for (var z = -1; z <= 1; z++) {
|
||||
var offset = pos.offset(x, y, z);
|
||||
var state = level.getBlockState(offset);
|
||||
if (state.getBlock().getTags().contains(BlockTags.LOGS.getName()) || includeLeaves && state.getBlock() instanceof LeavesBlock) {
|
||||
if (drop) {
|
||||
level.destroyBlock(offset, true);
|
||||
|
@ -153,20 +153,20 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
if (!Multiblocks.TREE_RITUAL.isComplete(this.level, this.ritualPos)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
BlockState state = this.level.getBlockState(this.ritualPos.above(i));
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var state = this.level.getBlockState(this.ritualPos.above(i));
|
||||
if (!(state.getBlock().getTags().contains(BlockTags.LOGS.getName())))
|
||||
return false;
|
||||
}
|
||||
if (this.timer < this.recipe.time / 2) {
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(this.recipe.ingredients));
|
||||
boolean fine = Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
BlockEntity tile = this.level.getBlockEntity(pos);
|
||||
var fine = Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
var tile = this.level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityWoodStand) {
|
||||
ItemStack stack = ((BlockEntityWoodStand) tile).items.getStackInSlot(0);
|
||||
var stack = ((BlockEntityWoodStand) tile).items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
for (int i = required.size() - 1; i >= 0; i--) {
|
||||
Ingredient req = required.get(i);
|
||||
for (var i = required.size() - 1; i >= 0; i--) {
|
||||
var req = required.get(i);
|
||||
if (req.test(stack)) {
|
||||
required.remove(i);
|
||||
return true;
|
||||
|
|
|
@ -1,48 +1,47 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
|
||||
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.Model;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
||||
|
||||
public class RenderAuraTimer extends BlockEntityRenderer<BlockEntityAuraTimer> {
|
||||
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(BlockEntityRendererDispatcher disp) {
|
||||
super(disp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntityAuraTimer tile, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack bottle = tile.getItemHandler().getStackInSlot(0);
|
||||
public void render(BlockEntityAuraTimer tile, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
var bottle = tile.getItemHandler().getStackInSlot(0);
|
||||
if (bottle.isEmpty())
|
||||
return;
|
||||
stack.push();
|
||||
stack.pushPose();
|
||||
stack.translate(4 / 16F, 2.001F / 16, 4 / 16F);
|
||||
|
||||
float percentage = 1 - tile.getTimerPercentage();
|
||||
var percentage = 1 - tile.getTimerPercentage();
|
||||
stack.scale(8 / 16F, 6.5F / 16 * percentage, 8 / 16F);
|
||||
|
||||
IAuraType type = ItemAuraBottle.getType(bottle);
|
||||
float r = (type.getColor() >> 16 & 255) / 255F;
|
||||
float g = (type.getColor() >> 8 & 255) / 255F;
|
||||
float b = (type.getColor() & 255) / 255F;
|
||||
this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F);
|
||||
stack.pop();
|
||||
var type = ItemAuraBottle.getType(bottle);
|
||||
var r = (type.getColor() >> 16 & 255) / 255F;
|
||||
var g = (type.getColor() >> 8 & 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);
|
||||
stack.popPose();
|
||||
|
||||
}
|
||||
|
||||
private static class AuraModel extends Model {
|
||||
// TODO model rendering
|
||||
/* private static class AuraModel extends Model {
|
||||
|
||||
private final ModelRenderer box;
|
||||
|
||||
|
@ -57,5 +56,5 @@ public class RenderAuraTimer extends BlockEntityRenderer<BlockEntityAuraTimer> {
|
|||
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -7,16 +7,21 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
|
|||
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.BlockEntityRendererProvider;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCrate> {
|
||||
|
||||
public RenderEnderCrate(BlockEntityRendererProvider.Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntityEnderCrate tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
Matrix4f matrix4f = matrixStackIn.last().pose();
|
||||
float f1 = RenderEnderCrate.getOffsetUp();
|
||||
var matrix4f = matrixStackIn.last().pose();
|
||||
var f1 = RenderEnderCrate.getOffsetUp();
|
||||
RenderEnderCrate.renderFace(matrix4f, bufferIn.getBuffer(RenderEnderCrate.renderType()), f1, f1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,52 +1,50 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.Model;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.BlockEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RenderGeneratorLimitRemover extends BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
|
||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
|
||||
private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
||||
public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
|
||||
|
||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
|
||||
//private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
||||
|
||||
public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) {
|
||||
|
||||
public RenderGeneratorLimitRemover(BlockEntityRendererDispatcher disp) {
|
||||
super(disp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntityGeneratorLimitRemover te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
BlockEntity above = te.getLevel().getBlockEntity(te.getPos().up());
|
||||
public void render(BlockEntityGeneratorLimitRemover te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
var above = te.getLevel().getBlockEntity(te.getBlockPos().above());
|
||||
if (above instanceof BlockEntityImpl && ((BlockEntityImpl) above).wantsLimitRemover()) {
|
||||
this.renderGlint(matrixStack, iRenderTypeBuffer, 1, combinedOverlayIn);
|
||||
this.renderGlint(matrixStack, iRenderTypeBuffer, 0, combinedOverlayIn);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGlint(MatrixStack stack, IRenderTypeBuffer buffer, double yOff, int combinedOverlayIn) {
|
||||
stack.push();
|
||||
int brightness = 15 << 20 | 15 << 4;
|
||||
float alpha = ((float) Math.sin(System.currentTimeMillis() / 800D) + 1F) / 2F;
|
||||
private void renderGlint(PoseStack stack, MultiBufferSource buffer, double yOff, int combinedOverlayIn) {
|
||||
stack.pushPose();
|
||||
var brightness = 15 << 20 | 15 << 4;
|
||||
var alpha = ((float) Math.sin(System.currentTimeMillis() / 800D) + 1F) / 2F;
|
||||
stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F);
|
||||
stack.rotate(Vector3f.XP.rotationDegrees(180F));
|
||||
stack.mulPose(Vector3f.XP.rotationDegrees(180F));
|
||||
stack.scale(1.002F, 1.002F, 1.002F);
|
||||
this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha);
|
||||
stack.pop();
|
||||
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha);
|
||||
stack.popPose();
|
||||
}
|
||||
|
||||
private static class ModelLimitRemoverGlint extends Model {
|
||||
// TODO model rendering
|
||||
/* private static class ModelLimitRemoverGlint extends Model {
|
||||
|
||||
private final ModelRenderer box;
|
||||
|
||||
|
@ -61,5 +59,5 @@ public class RenderGeneratorLimitRemover extends BlockEntityRenderer<BlockEntity
|
|||
public void render(MatrixStack matrixStack, IVertexBuilder iVertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||
this.box.render(matrixStack, iVertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class RenderNatureAltar implements BlockEntityRenderer<BlockEntityNatureAltar> {
|
||||
|
||||
public RenderNatureAltar(BlockEntityRendererProvider.Context context) {
|
||||
|
||||
public class RenderNatureAltar extends BlockEntityRenderer<BlockEntityNatureAltar> {
|
||||
public RenderNatureAltar(BlockEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack stack = tileEntityIn.items.getStackInSlot(0);
|
||||
public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
var stack = tileEntityIn.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
matrixStackIn.push();
|
||||
float time = tileEntityIn.bobTimer + partialTicks;
|
||||
float bob = (float) Math.sin(time / 10F) * 0.1F;
|
||||
matrixStackIn.pushPose();
|
||||
var time = tileEntityIn.bobTimer + partialTicks;
|
||||
var bob = (float) Math.sin(time / 10F) * 0.1F;
|
||||
matrixStackIn.translate(0.5F, 1.2F + bob, 0.5F);
|
||||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(time * 3 % 360));
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn);
|
||||
matrixStackIn.pop();
|
||||
matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(time * 3 % 360));
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn, 0);
|
||||
matrixStackIn.popPose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Mth;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RenderOfferingTable extends BlockEntityRenderer<BlockEntityOfferingTable> {
|
||||
public class RenderOfferingTable implements BlockEntityRenderer<BlockEntityOfferingTable> {
|
||||
|
||||
private final Random rand = new Random();
|
||||
|
||||
public RenderOfferingTable(BlockEntityRendererDispatcher disp) {
|
||||
super(disp);
|
||||
public RenderOfferingTable(BlockEntityRendererProvider.Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntityOfferingTable tileEntityOfferingTable, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack stack = tileEntityOfferingTable.items.getStackInSlot(0);
|
||||
public void render(BlockEntityOfferingTable tileEntityOfferingTable, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
var stack = tileEntityOfferingTable.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
this.rand.setSeed(Item.getIdFromItem(stack.getItem()) + stack.getDamage());
|
||||
this.rand.setSeed(Item.getId(stack.getItem()) + stack.getDamageValue());
|
||||
|
||||
int amount = Mth.ceil(stack.getCount() / 2F);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
matrixStack.push();
|
||||
Item item = stack.getItem();
|
||||
var amount = Mth.ceil(stack.getCount() / 2F);
|
||||
for (var i = 0; i < amount; i++) {
|
||||
matrixStack.pushPose();
|
||||
var item = stack.getItem();
|
||||
|
||||
float scale;
|
||||
float yOff;
|
||||
|
@ -48,12 +48,12 @@ public class RenderOfferingTable extends BlockEntityRenderer<BlockEntityOffering
|
|||
0.35F + this.rand.nextFloat() * 0.3F,
|
||||
0.9F + yOff + i * 0.001F,
|
||||
0.35F + this.rand.nextFloat() * 0.3F);
|
||||
matrixStack.rotate(Vector3f.YP.rotationDegrees(this.rand.nextFloat() * 360));
|
||||
matrixStack.rotate(Vector3f.XP.rotationDegrees(90F));
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(this.rand.nextFloat() * 360));
|
||||
matrixStack.mulPose(Vector3f.XP.rotationDegrees(90F));
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, combinedLightIn, combinedOverlayIn, matrixStack, iRenderTypeBuffer);
|
||||
matrixStack.pop();
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, combinedLightIn, combinedOverlayIn, matrixStack, iRenderTypeBuffer, 0);
|
||||
matrixStack.popPose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,64 +1,62 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.Model;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RenderProjectileGenerator extends BlockEntityRenderer<BlockEntityProjectileGenerator> {
|
||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
||||
private final ModelOverlay model = new ModelOverlay();
|
||||
public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> {
|
||||
|
||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
||||
//private final ModelOverlay model = new ModelOverlay();
|
||||
|
||||
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
|
||||
|
||||
public RenderProjectileGenerator(BlockEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntityProjectileGenerator te, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
stack.push();
|
||||
public void render(BlockEntityProjectileGenerator te, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
stack.pushPose();
|
||||
if (te.nextSide == Direction.NORTH) {
|
||||
stack.rotate(Vector3f.YP.rotationDegrees(270));
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(270));
|
||||
stack.translate(-0.002F, 0, -1);
|
||||
} else if (te.nextSide == Direction.EAST) {
|
||||
stack.rotate(Vector3f.YP.rotationDegrees(180));
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||
stack.translate(-1.002F, 0, -1);
|
||||
} else if (te.nextSide == Direction.SOUTH) {
|
||||
stack.rotate(Vector3f.YP.rotationDegrees(90));
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(90));
|
||||
stack.translate(-1.002F, 0, 0);
|
||||
} else {
|
||||
stack.translate(-0.002F, 0, 0);
|
||||
}
|
||||
int brightness = 15 << 20 | 15 << 4;
|
||||
this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
|
||||
stack.pop();
|
||||
var brightness = 15 << 20 | 15 << 4;
|
||||
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
|
||||
stack.popPose();
|
||||
}
|
||||
|
||||
private static class ModelOverlay extends Model {
|
||||
// TODO model rendering
|
||||
/* private static class ModelOverlay extends Model {
|
||||
|
||||
private final ModelRenderer box;
|
||||
private final ModelPart box;
|
||||
|
||||
public ModelOverlay() {
|
||||
super(RenderType::getEntityTranslucent);
|
||||
this.box = new ModelRenderer(this, 0, 0);
|
||||
super(RenderType::entityTranslucent);
|
||||
this.box = new ModelPart(this, 0, 0);
|
||||
this.box.setTextureSize(64, 64);
|
||||
this.box.addBox(0, 0, 0, 16, 16, 16);
|
||||
this.box.(0, 0, 0, 16, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue