mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
var
This commit is contained in:
parent
24cf4ae186
commit
65cce7fae5
144 changed files with 1112 additions and 1114 deletions
|
@ -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) {
|
||||
|
|
|
@ -45,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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
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.below()).isCollisionShapeFullBlock(levelIn, pos)) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAncientLeaves) {
|
||||
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
|
@ -72,7 +72,7 @@ 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.setBlockAndUpdate(pos, ModBlocks.DECAYED_LEAVES.defaultBlockState());
|
||||
|
|
|
@ -8,7 +8,6 @@ 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.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -37,9 +36,9 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(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 AABB(pos).inflate(radius);
|
||||
}
|
||||
|
|
|
@ -38,42 +38,42 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
|
|||
|
||||
@SubscribeEvent
|
||||
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
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();
|
||||
var entity = event.getEntityLiving();
|
||||
if (entity.level.isClientSide || !(entity instanceof Animal) || entity instanceof Mob || entity instanceof Npc)
|
||||
return;
|
||||
BlockPos pos = entity.blockPosition();
|
||||
var pos = entity.blockPosition();
|
||||
Helper.getBlockEntitiesInArea(entity.level, pos, 5, tile -> {
|
||||
if (!(tile instanceof BlockEntityAnimalGenerator gen))
|
||||
return false;
|
||||
|
||||
CompoundTag data = entity.getPersistentData();
|
||||
var data = entity.getPersistentData();
|
||||
data.putBoolean(NaturesAura.MOD_ID + ":no_drops", true);
|
||||
|
||||
if (gen.isBusy())
|
||||
return false;
|
||||
|
||||
boolean child = entity.isBaby();
|
||||
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.getBlockPos();
|
||||
var genPos = gen.getBlockPos();
|
||||
PacketHandler.sendToAllAround(entity.level, pos, 32, new PacketParticles(
|
||||
(float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME,
|
||||
child ? 1 : 0,
|
||||
|
@ -86,14 +86,14 @@ 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class BlockAuraDetector extends BlockContainerImpl {
|
|||
|
||||
@Override
|
||||
public int getAnalogOutputSignal(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAuraDetector detector)
|
||||
return detector.redstonePower;
|
||||
else
|
||||
|
|
|
@ -21,7 +21,7 @@ public class BlockCatalyst extends BlockImpl implements ICustomBlockState {
|
|||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
return super.getStateForPlacement(context).setValue(NETHER, nether);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(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 AABB(
|
||||
(pos.getX() - range) >> 4 << 4,
|
||||
|
@ -60,10 +60,10 @@ 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.random.nextFloat(), pos.getY() + levelIn.random.nextFloat(), pos.getZ() + levelIn.random.nextFloat(),
|
||||
0, 0, 0, 0xa12dff, 1F + levelIn.random.nextFloat(), 100, 0, false, true);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -49,22 +49,22 @@ public class BlockEndFlower 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);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDragonTick(LivingUpdateEvent event) {
|
||||
LivingEntity living = event.getEntityLiving();
|
||||
var living = event.getEntityLiving();
|
||||
if (living.level.isClientSide || !(living instanceof EnderDragon dragon))
|
||||
return;
|
||||
if (dragon.deathTime < 150 || dragon.deathTime % 10 != 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int x = dragon.level.random.nextInt(256) - 128;
|
||||
int z = dragon.level.random.nextInt(256) - 128;
|
||||
BlockPos pos = new BlockPos(x, dragon.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z);
|
||||
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.below()).getBlock() != Blocks.END_STONE)
|
||||
|
@ -102,7 +102,7 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
|
|||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
BlockEntity tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
|
||||
var tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
|
||||
if (tile instanceof BlockEntityEndFlower && ((BlockEntityEndFlower) tile).isDrainMode)
|
||||
return NonNullList.create();
|
||||
return super.getDrops(state, builder);
|
||||
|
|
|
@ -26,7 +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.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -57,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 {
|
||||
|
@ -70,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());
|
||||
|
@ -91,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);
|
||||
|
@ -109,14 +108,14 @@ 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);
|
||||
}
|
||||
|
|
|
@ -33,17 +33,17 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
|||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult p_225533_6_) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFieldCreator) {
|
||||
if (!levelIn.isClientSide) {
|
||||
String key = NaturesAura.MOD_ID + ":field_creator_pos";
|
||||
CompoundTag compound = player.getPersistentData();
|
||||
var key = NaturesAura.MOD_ID + ":field_creator_pos";
|
||||
var compound = player.getPersistentData();
|
||||
if (!player.isCrouching() && compound.contains(key)) {
|
||||
BlockPos stored = BlockPos.of(compound.getLong(key));
|
||||
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile;
|
||||
var stored = BlockPos.of(compound.getLong(key));
|
||||
var creator = (BlockEntityFieldCreator) tile;
|
||||
if (!pos.equals(stored)) {
|
||||
if (creator.isCloseEnough(stored)) {
|
||||
BlockEntity otherTile = levelIn.getBlockEntity(stored);
|
||||
var otherTile = levelIn.getBlockEntity(stored);
|
||||
if (otherTile instanceof BlockEntityFieldCreator otherCreator) {
|
||||
creator.connectionOffset = stored.subtract(pos);
|
||||
creator.isMain = true;
|
||||
|
@ -74,9 +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);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFieldCreator creator && creator.isCharged) {
|
||||
BlockPos connected = creator.getConnectedPos();
|
||||
var connected = creator.getConnectedPos();
|
||||
if (connected != null)
|
||||
NaturesAuraAPI.instance().spawnParticleStream(
|
||||
pos.getX() + 0.25F + rand.nextFloat() * 0.5F,
|
||||
|
|
|
@ -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);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityFurnaceHeater heater && heater.isActive) {
|
||||
Direction facing = stateIn.getValue(FACING);
|
||||
var facing = stateIn.getValue(FACING);
|
||||
|
||||
float x;
|
||||
float y;
|
||||
|
|
|
@ -43,11 +43,11 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
}
|
||||
|
||||
private static int getShapeIndex(BlockState state) {
|
||||
int i = 0;
|
||||
boolean n = state.getValue(NORTH) != RedstoneSide.NONE;
|
||||
boolean e = state.getValue(EAST) != RedstoneSide.NONE;
|
||||
boolean s = state.getValue(SOUTH) != RedstoneSide.NONE;
|
||||
boolean w = state.getValue(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.ordinal();
|
||||
|
@ -82,7 +82,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockGetter iblockreader = context.getLevel();
|
||||
BlockPos blockpos = context.getClickedPos();
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -96,12 +96,12 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
}
|
||||
|
||||
private RedstoneSide getSide(BlockGetter levelIn, BlockPos pos, Direction face) {
|
||||
BlockPos blockpos = pos.relative(face);
|
||||
BlockState blockstate = levelIn.getBlockState(blockpos);
|
||||
BlockPos blockpos1 = pos.above();
|
||||
BlockState blockstate1 = levelIn.getBlockState(blockpos1);
|
||||
var blockpos = pos.relative(face);
|
||||
var blockstate = levelIn.getBlockState(blockpos);
|
||||
var blockpos1 = pos.above();
|
||||
var blockstate1 = levelIn.getBlockState(blockpos1);
|
||||
if (!blockstate1.isCollisionShapeFullBlock(levelIn, blockpos1)) {
|
||||
boolean flag = blockstate.isFaceSturdy(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
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;
|
||||
|
@ -115,14 +115,14 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
}
|
||||
|
||||
protected boolean canConnectTo(BlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
var block = blockState.getBlock();
|
||||
return block == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader levelIn, BlockPos pos) {
|
||||
BlockPos blockpos = pos.below();
|
||||
BlockState blockstate = levelIn.getBlockState(blockpos);
|
||||
var blockpos = pos.below();
|
||||
var blockstate = levelIn.getBlockState(blockpos);
|
||||
return blockstate.isFaceSturdy(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
}
|
||||
|
||||
|
@ -134,14 +134,14 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
@Override
|
||||
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) {
|
||||
for (var direction : Direction.Plane.VERTICAL) {
|
||||
levelIn.updateNeighborsAt(pos.relative(direction), this);
|
||||
}
|
||||
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
|
||||
for (var direction1 : Direction.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, pos.relative(direction1));
|
||||
}
|
||||
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos = pos.relative(direction2);
|
||||
for (var direction2 : Direction.Plane.HORIZONTAL) {
|
||||
var blockpos = pos.relative(direction2);
|
||||
if (levelIn.getBlockState(blockpos).isCollisionShapeFullBlock(levelIn, blockpos)) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.above());
|
||||
} else {
|
||||
|
@ -157,14 +157,14 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
if (!isMoving && state.getBlock() != newState.getBlock()) {
|
||||
super.onRemove(state, levelIn, pos, newState, isMoving);
|
||||
if (!levelIn.isClientSide) {
|
||||
for (Direction direction : Direction.values()) {
|
||||
for (var direction : Direction.values()) {
|
||||
levelIn.updateNeighborsAt(pos.relative(direction), this);
|
||||
}
|
||||
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
|
||||
for (var direction1 : Direction.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, pos.relative(direction1));
|
||||
}
|
||||
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos = pos.relative(direction2);
|
||||
for (var direction2 : Direction.Plane.HORIZONTAL) {
|
||||
var blockpos = pos.relative(direction2);
|
||||
if (levelIn.getBlockState(blockpos).isCollisionShapeFullBlock(levelIn, blockpos)) {
|
||||
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.above());
|
||||
} else {
|
||||
|
@ -188,23 +188,23 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
|
||||
@Override
|
||||
public void updateIndirectNeighbourShapes(BlockState state, LevelAccessor levelIn, BlockPos pos, int flags, int recursionLeft) {
|
||||
BlockPos.MutableBlockPos pool = new BlockPos.MutableBlockPos();
|
||||
for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||
RedstoneSide redstoneside = state.getValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(direction));
|
||||
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.relative(direction.getOpposite());
|
||||
BlockState blockstate1 = blockstate.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos);
|
||||
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.set(pos).move(direction).move(Direction.UP);
|
||||
BlockState blockstate3 = levelIn.getBlockState(pool);
|
||||
var blockstate3 = levelIn.getBlockState(pool);
|
||||
if (blockstate3.getBlock() != Blocks.OBSERVER) {
|
||||
BlockPos blockpos1 = pool.relative(direction.getOpposite());
|
||||
BlockState blockstate2 = blockstate3.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1);
|
||||
var blockpos1 = pool.relative(direction.getOpposite());
|
||||
var blockstate2 = blockstate3.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1);
|
||||
updateOrDestroy(blockstate3, blockstate2, levelIn, pool, flags);
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
if (levelIn.getBlockState(pos).getBlock() == this) {
|
||||
levelIn.updateNeighborsAt(pos, this);
|
||||
|
||||
for (Direction direction : Direction.values()) {
|
||||
for (var direction : Direction.values()) {
|
||||
levelIn.updateNeighborsAt(pos.relative(direction), this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
}
|
||||
|
||||
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.setBlockAndUpdate(pos, ModBlocks.GOLDEN_LEAVES.defaultBlockState()
|
||||
|
@ -74,9 +74,9 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public BlockColor getBlockColor() {
|
||||
return (state, levelIn, pos, tintIndex) -> {
|
||||
int color = 0xF2FF00;
|
||||
var color = 0xF2FF00;
|
||||
if (state != null && levelIn != null && pos != null) {
|
||||
int foliage = BiomeColors.getAverageFoliageColor(levelIn, pos);
|
||||
var foliage = BiomeColors.getAverageFoliageColor(levelIn, pos);
|
||||
return Helper.blendColors(color, foliage, state.getValue(STAGE) / (float) HIGHEST_STAGE);
|
||||
} else {
|
||||
return color;
|
||||
|
@ -100,7 +100,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
|
|||
}
|
||||
|
||||
if (stage > 1) {
|
||||
BlockPos offset = pos.relative(Direction.getRandom(random));
|
||||
var offset = pos.relative(Direction.getRandom(random));
|
||||
if (levelIn.isLoaded(offset))
|
||||
convert(levelIn, offset);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
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 BlockEntityGratedChute chute))
|
||||
return InteractionResult.FAIL;
|
||||
if (!levelIn.isClientSide) {
|
||||
|
@ -102,7 +102,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
Direction newFacing = context.getClickedFace().getOpposite();
|
||||
var newFacing = context.getClickedFace().getOpposite();
|
||||
if (newFacing == Direction.UP)
|
||||
newFacing = Direction.DOWN;
|
||||
return super.getStateForPlacement(context).setValue(FACING, newFacing);
|
||||
|
@ -120,10 +120,10 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
|
||||
@Override
|
||||
public int getAnalogOutputSignal(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(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);
|
||||
|
|
|
@ -23,11 +23,11 @@ public class BlockItemDistributor extends BlockContainerImpl implements ICustomB
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
|
|||
@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,
|
||||
|
|
|
@ -69,7 +69,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
|||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
||||
return super.getStateForPlacement(context).setValue(NETHER, nether);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
|
|||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
|
||||
BlockPos up = pos.above();
|
||||
BlockState upState = levelIn.getBlockState(up);
|
||||
var up = pos.above();
|
||||
var upState = levelIn.getBlockState(up);
|
||||
if (upState.isFaceSturdy(levelIn, up, Direction.DOWN))
|
||||
levelIn.setBlockAndUpdate(pos, Blocks.NETHERRACK.defaultBlockState());
|
||||
}
|
||||
|
@ -47,16 +47,16 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
|
|||
|
||||
@Override
|
||||
public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
|
||||
BlockPos blockpos = pos.above();
|
||||
BlockState blockstate = Blocks.GRASS.defaultBlockState();
|
||||
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) {
|
||||
((BonemealableBlock) blockstate.getBlock()).performBonemeal(level, rand, blockpos1, blockstate2);
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
|||
@SubscribeEvent
|
||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
var level = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
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);
|
||||
|
||||
|
|
|
@ -31,17 +31,17 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
|||
|
||||
@SubscribeEvent
|
||||
public void onPickup(EntityItemPickupEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
var player = event.getPlayer();
|
||||
if (player != null && !player.isCrouching()) {
|
||||
ItemEntity item = event.getItem();
|
||||
BlockPos pos = item.blockPosition();
|
||||
var item = event.getItem();
|
||||
var pos = item.blockPosition();
|
||||
Helper.getBlockEntitiesInArea(item.level, pos, 8, tile -> {
|
||||
if (!(tile instanceof BlockEntityPickupStopper stopper))
|
||||
return false;
|
||||
float radius = stopper.getRadius();
|
||||
var radius = stopper.getRadius();
|
||||
if (radius <= 0F)
|
||||
return false;
|
||||
BlockPos stopperPos = stopper.getBlockPos();
|
||||
var stopperPos = stopper.getBlockPos();
|
||||
if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
|
||||
return false;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityPickupStopper) {
|
||||
double radius = ((BlockEntityPickupStopper) tile).getRadius();
|
||||
if (radius > 0)
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
|
||||
@Override
|
||||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||
ThrownEnderpearl ret = new ThrownEnderpearl(EntityType.ENDER_PEARL, levelIn);
|
||||
var ret = new ThrownEnderpearl(EntityType.ENDER_PEARL, levelIn);
|
||||
ret.setPos(position.x(), position.y(), position.z());
|
||||
return ret;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
DispenserBlock.registerBehavior(Items.TRIDENT, new AbstractProjectileDispenseBehavior() {
|
||||
@Override
|
||||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||
ThrownTrident ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
|
||||
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;
|
||||
|
@ -64,21 +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;
|
||||
HitResult ray = event.getRayTraceResult();
|
||||
var ray = event.getRayTraceResult();
|
||||
if (!(ray instanceof BlockHitResult blockRay))
|
||||
return;
|
||||
BlockPos pos = blockRay.getBlockPos();
|
||||
var pos = blockRay.getBlockPos();
|
||||
if (pos == null)
|
||||
return;
|
||||
BlockEntity tile = entity.level.getBlockEntity(pos);
|
||||
var tile = entity.level.getBlockEntity(pos);
|
||||
if (!(tile instanceof BlockEntityProjectileGenerator generator))
|
||||
return;
|
||||
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))
|
||||
|
|
|
@ -48,10 +48,10 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
|
|||
|
||||
@SubscribeEvent
|
||||
public void onLivingDeath(LivingDeathEvent event) {
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
var entity = event.getEntityLiving();
|
||||
if (!(entity instanceof Slime slime) || entity.level.isClientSide)
|
||||
return;
|
||||
int size = slime.getSize();
|
||||
var size = slime.getSize();
|
||||
if (size <= 1)
|
||||
return;
|
||||
Helper.getBlockEntitiesInArea(entity.level, entity.blockPosition(), 8, tile -> {
|
||||
|
|
|
@ -21,9 +21,9 @@ public class BlockSnowCreator extends BlockContainerImpl implements IVisualizabl
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(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 AABB(pos).inflate(radius);
|
||||
}
|
||||
|
|
|
@ -53,26 +53,26 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
|||
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if (event.getSpawner() != null)
|
||||
return;
|
||||
LevelAccessor level = event.getWorld();
|
||||
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.getBlockPos();
|
||||
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;
|
||||
|
||||
Mob entity = (Mob) event.getEntityLiving();
|
||||
var entity = (Mob) event.getEntityLiving();
|
||||
if (entity.checkSpawnRules(level, event.getSpawnReason()) && entity.checkSpawnObstruction(level)) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot((Level) level, lampPos, 32, lampPos);
|
||||
var spot = IAuraChunk.getHighestSpot((Level) level, lampPos, 32, lampPos);
|
||||
IAuraChunk.getAuraChunk((Level) level, spot).drainAura(spot, 200);
|
||||
|
||||
PacketHandler.sendToAllAround((ServerLevel) level, lampPos, 32,
|
||||
|
@ -92,9 +92,9 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
|||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
||||
BlockEntity tile = level.getBlockEntity(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 AABB(pos).inflate(radius);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
|
|||
|
||||
@Override
|
||||
public ItemStack pickupBlock(LevelAccessor levelIn, BlockPos pos, BlockState state) {
|
||||
BlockEntity tile = levelIn.getBlockEntity(pos);
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntitySpring)
|
||||
((BlockEntitySpring) tile).consumeAura(2500);
|
||||
return new ItemStack(Items.WATER_BUCKET); }
|
||||
|
|
|
@ -58,25 +58,25 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
|||
|
||||
@SubscribeEvent
|
||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
LevelAccessor level = event.getWorld();
|
||||
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().getCloneItemStack(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().getRecipesFor(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);
|
||||
var fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> {
|
||||
var tile = level.getBlockEntity(tilePos);
|
||||
if (tile instanceof BlockEntityWoodStand stand) {
|
||||
ItemStack stack = stand.items.getStackInSlot(0);
|
||||
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);
|
||||
|
||||
|
|
|
@ -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,10 +90,10 @@ 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.check() != null)
|
||||
|
@ -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);
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -22,19 +22,19 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
|
|||
|
||||
@Override
|
||||
public void render(BlockEntityAuraTimer tile, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack bottle = tile.getItemHandler().getStackInSlot(0);
|
||||
var bottle = tile.getItemHandler().getStackInSlot(0);
|
||||
if (bottle.isEmpty())
|
||||
return;
|
||||
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;
|
||||
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();
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCra
|
|||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
|
|||
|
||||
@Override
|
||||
public void render(BlockEntityGeneratorLimitRemover te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
BlockEntity above = te.getLevel().getBlockEntity(te.getBlockPos().above());
|
||||
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);
|
||||
|
@ -34,8 +34,8 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
|
|||
|
||||
private void renderGlint(PoseStack stack, MultiBufferSource buffer, double yOff, int combinedOverlayIn) {
|
||||
stack.pushPose();
|
||||
int brightness = 15 << 20 | 15 << 4;
|
||||
float alpha = ((float) Math.sin(System.currentTimeMillis() / 800D) + 1F) / 2F;
|
||||
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.mulPose(Vector3f.XP.rotationDegrees(180F));
|
||||
stack.scale(1.002F, 1.002F, 1.002F);
|
||||
|
|
|
@ -18,11 +18,11 @@ public class RenderNatureAltar implements BlockEntityRenderer<BlockEntityNatureA
|
|||
|
||||
@Override
|
||||
public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack stack = tileEntityIn.items.getStackInSlot(0);
|
||||
var stack = tileEntityIn.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
matrixStackIn.pushPose();
|
||||
float time = tileEntityIn.bobTimer + partialTicks;
|
||||
float bob = (float) Math.sin(time / 10F) * 0.1F;
|
||||
var time = tileEntityIn.bobTimer + partialTicks;
|
||||
var bob = (float) Math.sin(time / 10F) * 0.1F;
|
||||
matrixStackIn.translate(0.5F, 1.2F + bob, 0.5F);
|
||||
matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(time * 3 % 360));
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn, 0);
|
||||
|
|
|
@ -25,14 +25,14 @@ public class RenderOfferingTable implements BlockEntityRenderer<BlockEntityOffer
|
|||
|
||||
@Override
|
||||
public void render(BlockEntityOfferingTable tileEntityOfferingTable, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack stack = tileEntityOfferingTable.items.getStackInSlot(0);
|
||||
var stack = tileEntityOfferingTable.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
this.rand.setSeed(Item.getId(stack.getItem()) + stack.getDamageValue());
|
||||
|
||||
int amount = Mth.ceil(stack.getCount() / 2F);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
var amount = Mth.ceil(stack.getCount() / 2F);
|
||||
for (var i = 0; i < amount; i++) {
|
||||
matrixStack.pushPose();
|
||||
Item item = stack.getItem();
|
||||
var item = stack.getItem();
|
||||
|
||||
float scale;
|
||||
float yOff;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntit
|
|||
} else {
|
||||
stack.translate(-0.002F, 0, 0);
|
||||
}
|
||||
int brightness = 15 << 20 | 15 << 4;
|
||||
var brightness = 15 << 20 | 15 << 4;
|
||||
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
|
||||
stack.popPose();
|
||||
}
|
||||
|
|
|
@ -20,17 +20,17 @@ public class RenderWoodStand implements BlockEntityRenderer<BlockEntityWoodStand
|
|||
|
||||
@Override
|
||||
public void render(BlockEntityWoodStand tileEntityWoodStand, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int i, int i1) {
|
||||
ItemStack stack = tileEntityWoodStand.items.getStackInSlot(0);
|
||||
var stack = tileEntityWoodStand.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
matrixStack.pushPose();
|
||||
Item item = stack.getItem();
|
||||
var item = stack.getItem();
|
||||
if (item instanceof BlockItem blockItem && blockItem.getBlock().defaultBlockState().getMaterial().isSolid()) {
|
||||
matrixStack.translate(0.5F, 0.755F, 0.5F);
|
||||
float scale = 0.95F;
|
||||
var scale = 0.95F;
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
} else {
|
||||
matrixStack.translate(0.5F, 0.825F, 0.4F);
|
||||
float scale = 0.75F;
|
||||
var scale = 0.75F;
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
matrixStack.mulPose(Vector3f.XP.rotationDegrees(90));
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ public class AngerEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot >= 0)
|
||||
return false;
|
||||
int aura = IAuraChunk.getAuraInArea(level, pos, 50);
|
||||
var aura = IAuraChunk.getAuraInArea(level, pos, 50);
|
||||
if (aura > 0)
|
||||
return false;
|
||||
int dist = Math.min(Math.abs(aura) / 50000, 75);
|
||||
var dist = Math.min(Math.abs(aura) / 50000, 75);
|
||||
if (dist < 10)
|
||||
return false;
|
||||
this.bb = new AABB(pos).inflate(dist);
|
||||
|
@ -58,11 +58,11 @@ public class AngerEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
|
||||
for (LivingEntity entity : entities) {
|
||||
var entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
|
||||
for (var entity : entities) {
|
||||
if (!(entity instanceof NeutralMob))
|
||||
continue;
|
||||
Player player = level.getNearestPlayer(entity, 25);
|
||||
var player = level.getNearestPlayer(entity, 25);
|
||||
if (player == null)
|
||||
continue;
|
||||
((NeutralMob) entity).setTarget(player);
|
||||
|
|
|
@ -37,14 +37,14 @@ public class AnimalEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot <= 0)
|
||||
return false;
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura < 1500000)
|
||||
return false;
|
||||
this.chance = Math.min(50, Mth.ceil(Math.abs(aura) / 500000F / auraAndSpots.getRight()));
|
||||
if (this.chance <= 0)
|
||||
return false;
|
||||
int dist = Mth.clamp(Math.abs(aura) / 150000, 5, 35);
|
||||
var dist = Mth.clamp(Math.abs(aura) / 150000, 5, 35);
|
||||
this.bb = new AABB(pos).inflate(dist);
|
||||
return true;
|
||||
}
|
||||
|
@ -72,18 +72,18 @@ public class AnimalEffect implements IDrainSpotEffect {
|
|||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
|
||||
List<Animal> animals = level.getEntitiesOfClass(Animal.class, this.bb);
|
||||
var animals = level.getEntitiesOfClass(Animal.class, this.bb);
|
||||
if (animals.size() >= ModConfig.instance.maxAnimalsAroundPowder.get())
|
||||
return;
|
||||
|
||||
List<ItemEntity> items = level.getEntitiesOfClass(ItemEntity.class, this.bb);
|
||||
for (ItemEntity item : items) {
|
||||
var items = level.getEntitiesOfClass(ItemEntity.class, this.bb);
|
||||
for (var item : items) {
|
||||
if (!item.isAlive())
|
||||
continue;
|
||||
if (!NaturesAuraAPI.instance().isEffectPowderActive(level, item.blockPosition(), NAME))
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
var stack = item.getItem();
|
||||
if (!(stack.getItem() instanceof EggItem))
|
||||
continue;
|
||||
if (item.getAge() < item.lifespan / 2)
|
||||
|
@ -96,44 +96,44 @@ public class AnimalEffect implements IDrainSpotEffect {
|
|||
item.setItem(stack);
|
||||
}
|
||||
|
||||
Chicken chicken = new Chicken(EntityType.CHICKEN, level);
|
||||
var chicken = new Chicken(EntityType.CHICKEN, level);
|
||||
chicken.setAge(-24000);
|
||||
chicken.setPos(item.getX(), item.getY(), item.getZ());
|
||||
level.addFreshEntity(chicken);
|
||||
|
||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, item.blockPosition(), 35, pos);
|
||||
var closestSpot = IAuraChunk.getHighestSpot(level, item.blockPosition(), 35, pos);
|
||||
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 2000);
|
||||
}
|
||||
|
||||
if (level.random.nextInt(20) <= this.chance) {
|
||||
if (animals.size() < 2)
|
||||
return;
|
||||
Animal first = animals.get(level.random.nextInt(animals.size()));
|
||||
var first = animals.get(level.random.nextInt(animals.size()));
|
||||
if (first.isBaby() || first.isInLove())
|
||||
return;
|
||||
if (!NaturesAuraAPI.instance().isEffectPowderActive(level, first.blockPosition(), NAME))
|
||||
return;
|
||||
|
||||
Optional<Animal> secondOptional = animals.stream()
|
||||
var secondOptional = animals.stream()
|
||||
.filter(e -> e != first && !e.isInLove() && !e.isBaby())
|
||||
.min(Comparator.comparingDouble(e -> e.distanceToSqr(first)));
|
||||
if (secondOptional.isEmpty())
|
||||
return;
|
||||
Animal second = secondOptional.get();
|
||||
var second = secondOptional.get();
|
||||
if (second.distanceToSqr(first) > 5 * 5)
|
||||
return;
|
||||
|
||||
this.setInLove(first);
|
||||
this.setInLove(second);
|
||||
|
||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, first.blockPosition(), 35, pos);
|
||||
var closestSpot = IAuraChunk.getHighestSpot(level, first.blockPosition(), 35, pos);
|
||||
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500);
|
||||
}
|
||||
}
|
||||
|
||||
private void setInLove(Animal animal) {
|
||||
animal.setInLove(null);
|
||||
for (int j = 0; j < 7; j++)
|
||||
for (var j = 0; j < 7; j++)
|
||||
animal.level.addParticle(ParticleTypes.HEART,
|
||||
animal.getX() + (double) (animal.level.random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
|
||||
animal.getY() + 0.5D + (double) (animal.level.random.nextFloat() * animal.getBbHeight()),
|
||||
|
|
|
@ -20,17 +20,17 @@ public class BalanceEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
if (level.getGameTime() % 200 != 0)
|
||||
return;
|
||||
int searchRadius = Math.min(45, spot / 10000);
|
||||
MutableInt positiveAura = new MutableInt();
|
||||
var searchRadius = Math.min(45, spot / 10000);
|
||||
var positiveAura = new MutableInt();
|
||||
IAuraChunk.getSpotsInArea(level, pos, searchRadius, (otherPos, otherSpot) -> {
|
||||
if (otherSpot > 0)
|
||||
positiveAura.add(otherSpot);
|
||||
});
|
||||
int radius = Math.min(80, positiveAura.intValue() / 5000);
|
||||
BlockPos lowestPos = IAuraChunk.getLowestSpot(level, pos, radius, null);
|
||||
var radius = Math.min(80, positiveAura.intValue() / 5000);
|
||||
var lowestPos = IAuraChunk.getLowestSpot(level, pos, radius, null);
|
||||
if (lowestPos == null)
|
||||
return;
|
||||
int stored = IAuraChunk.getAuraChunk(level, lowestPos).storeAura(lowestPos, spot / 50);
|
||||
var stored = IAuraChunk.getAuraChunk(level, lowestPos).storeAura(lowestPos, spot / 50);
|
||||
auraChunk.drainAura(pos, stored);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ public class BreathlessEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot >= 0)
|
||||
return false;
|
||||
int aura = IAuraChunk.getAuraInArea(level, pos, 50);
|
||||
var aura = IAuraChunk.getAuraInArea(level, pos, 50);
|
||||
if (aura > 0)
|
||||
return false;
|
||||
int dist = Math.min(Math.abs(aura) / 50000, 75);
|
||||
var dist = Math.min(Math.abs(aura) / 50000, 75);
|
||||
if (dist < 10)
|
||||
return false;
|
||||
this.amp = Math.min(Mth.floor(Math.abs(aura) / 2500000F), 3);
|
||||
|
@ -61,8 +61,8 @@ public class BreathlessEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
|
||||
for (LivingEntity entity : entities)
|
||||
var entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
|
||||
for (var entity : entities)
|
||||
entity.addEffect(new MobEffectInstance(ModPotions.BREATHLESS, 300, this.amp));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot < 100000)
|
||||
return false;
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 20);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 20);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura < 1500000)
|
||||
return false;
|
||||
int dist = Mth.clamp(aura / 3500, 3, 15);
|
||||
var dist = Mth.clamp(aura / 3500, 3, 15);
|
||||
this.bb = new AABB(pos).inflate(dist);
|
||||
this.amount = Mth.ceil(aura / 250F / auraAndSpots.getRight());
|
||||
return true;
|
||||
|
@ -59,8 +59,8 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
|
|||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
List<Player> players = level.getEntitiesOfClass(Player.class, this.bb);
|
||||
for (Player player : players) {
|
||||
var players = level.getEntitiesOfClass(Player.class, this.bb);
|
||||
for (var player : players) {
|
||||
if (NaturesAuraAPI.instance().isEffectPowderActive(level, player.blockPosition(), NAME))
|
||||
continue;
|
||||
if (NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, true)) {
|
||||
|
|
|
@ -26,10 +26,10 @@ public class ExplosionEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot >= 0)
|
||||
return false;
|
||||
int aura = IAuraChunk.getAuraInArea(level, pos, 85);
|
||||
var aura = IAuraChunk.getAuraInArea(level, pos, 85);
|
||||
if (aura > -5000000)
|
||||
return false;
|
||||
int chance = 140 - Math.abs(aura) / 200000;
|
||||
var chance = 140 - Math.abs(aura) / 200000;
|
||||
if (chance > 1 && level.random.nextInt(chance) != 0)
|
||||
return false;
|
||||
this.strength = Math.min(Math.abs(aura) / 5000000F, 5F);
|
||||
|
@ -60,9 +60,9 @@ public class ExplosionEffect implements IDrainSpotEffect {
|
|||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
|
||||
int x = Mth.floor(pos.getX() + level.random.nextGaussian() * this.dist);
|
||||
int z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist);
|
||||
BlockPos chosenPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z);
|
||||
var x = Mth.floor(pos.getX() + level.random.nextGaussian() * this.dist);
|
||||
var z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist);
|
||||
var chosenPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z);
|
||||
if (chosenPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(chosenPos)) {
|
||||
level.explode(null,
|
||||
chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5,
|
||||
|
|
|
@ -27,7 +27,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
|||
|
||||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot < 0) {
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 50);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 50);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura < 0) {
|
||||
this.amount = Math.min(300, Mth.ceil(Math.abs(aura) / 100000F / auraAndSpots.getRight()));
|
||||
|
@ -58,15 +58,15 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
|||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
BlockPos grassPos = new BlockPos(
|
||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
var grassPos = new BlockPos(
|
||||
pos.getX() + level.random.nextGaussian() * this.dist,
|
||||
pos.getY() + level.random.nextGaussian() * this.dist,
|
||||
pos.getZ() + level.random.nextGaussian() * this.dist
|
||||
);
|
||||
if (grassPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(grassPos)) {
|
||||
BlockState state = level.getBlockState(grassPos);
|
||||
Block block = state.getBlock();
|
||||
var state = level.getBlockState(grassPos);
|
||||
var block = state.getBlock();
|
||||
|
||||
BlockState newState = null;
|
||||
if (block instanceof LeavesBlock) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class NetherDecayEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot >= 0)
|
||||
return false;
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 50);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 50);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura >= 0)
|
||||
return false;
|
||||
|
@ -61,8 +61,8 @@ public class NetherDecayEffect implements IDrainSpotEffect {
|
|||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
BlockPos offset = new BlockPos(
|
||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
var offset = new BlockPos(
|
||||
pos.getX() + level.random.nextGaussian() * this.dist,
|
||||
pos.getY() + level.random.nextGaussian() * this.dist,
|
||||
pos.getZ() + level.random.nextGaussian() * this.dist);
|
||||
|
@ -71,7 +71,7 @@ public class NetherDecayEffect implements IDrainSpotEffect {
|
|||
|
||||
// degrade blocks
|
||||
Block degraded = null;
|
||||
BlockState state = level.getBlockState(offset);
|
||||
var state = level.getBlockState(offset);
|
||||
if (state.getBlock() == Blocks.GLOWSTONE) {
|
||||
degraded = Blocks.NETHERRACK;
|
||||
} else if (state.is(BlockTags.NYLIUM) || state.getBlock() == Blocks.NETHERRACK) {
|
||||
|
@ -86,7 +86,7 @@ public class NetherDecayEffect implements IDrainSpotEffect {
|
|||
|
||||
// ignite blocks
|
||||
if (BaseFireBlock.canBePlacedAt(level, offset, Direction.NORTH)) {
|
||||
BlockState fire = BaseFireBlock.getState(level, offset);
|
||||
var fire = BaseFireBlock.getState(level, offset);
|
||||
level.setBlockAndUpdate(offset, fire);
|
||||
level.levelEvent(1009, offset, 0);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class NetherGrassEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot <= 0)
|
||||
return false;
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura < 1500000)
|
||||
return false;
|
||||
|
@ -65,26 +65,26 @@ public class NetherGrassEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
int x = Mth.floor(pos.getX() + level.random.nextGaussian() * this.dist);
|
||||
int y = Mth.floor(pos.getY() + level.random.nextGaussian() * this.dist);
|
||||
int z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist);
|
||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
var x = Mth.floor(pos.getX() + level.random.nextGaussian() * this.dist);
|
||||
var y = Mth.floor(pos.getY() + level.random.nextGaussian() * this.dist);
|
||||
var z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist);
|
||||
|
||||
for (int yOff = -5; yOff <= 5; yOff++) {
|
||||
BlockPos goalPos = new BlockPos(x, y + yOff, z);
|
||||
for (var yOff = -5; yOff <= 5; yOff++) {
|
||||
var goalPos = new BlockPos(x, y + yOff, z);
|
||||
if (goalPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(goalPos)) {
|
||||
if (NaturesAuraAPI.instance().isEffectPowderActive(level, goalPos, NAME))
|
||||
continue;
|
||||
BlockPos up = goalPos.above();
|
||||
var up = goalPos.above();
|
||||
if (level.getBlockState(up).isFaceSturdy(level, up, Direction.DOWN))
|
||||
continue;
|
||||
|
||||
BlockState state = level.getBlockState(goalPos);
|
||||
Block block = state.getBlock();
|
||||
var state = level.getBlockState(goalPos);
|
||||
var block = state.getBlock();
|
||||
if (Tags.Blocks.NETHERRACK.contains(block)) {
|
||||
level.setBlockAndUpdate(goalPos, ModBlocks.NETHER_GRASS.defaultBlockState());
|
||||
|
||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos);
|
||||
var closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos);
|
||||
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500);
|
||||
|
||||
PacketHandler.sendToAllAround(level, goalPos, 32,
|
||||
|
|
|
@ -48,7 +48,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot <= 0)
|
||||
return false;
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura <= 2000000)
|
||||
return false;
|
||||
|
@ -81,7 +81,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
IAuraType type = auraChunk.getType();
|
||||
var type = auraChunk.getType();
|
||||
Block requiredBlock;
|
||||
List<WeightedOre> ores;
|
||||
if (type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)) {
|
||||
|
@ -91,51 +91,51 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
requiredBlock = Blocks.NETHERRACK;
|
||||
ores = NaturesAuraAPI.NETHER_ORES;
|
||||
}
|
||||
int totalWeight = WeightedRandom.getTotalWeight(ores);
|
||||
var totalWeight = WeightedRandom.getTotalWeight(ores);
|
||||
|
||||
List<Tuple<Vec3, Integer>> powders = NaturesAuraAPI.instance().getActiveEffectPowders(level,
|
||||
var powders = NaturesAuraAPI.instance().getActiveEffectPowders(level,
|
||||
new AABB(pos).inflate(this.dist), NAME);
|
||||
if (powders.isEmpty())
|
||||
return;
|
||||
for (int i = 0; i < this.amount; i++) {
|
||||
Tuple<Vec3, Integer> powder = powders.get(i % powders.size());
|
||||
Vec3 powderPos = powder.getA();
|
||||
for (var i = 0; i < this.amount; i++) {
|
||||
var powder = powders.get(i % powders.size());
|
||||
var powderPos = powder.getA();
|
||||
int range = powder.getB();
|
||||
int x = Mth.floor(powderPos.x + level.random.nextGaussian() * range);
|
||||
int y = Mth.floor(powderPos.y + level.random.nextGaussian() * range);
|
||||
int z = Mth.floor(powderPos.z + level.random.nextGaussian() * range);
|
||||
BlockPos orePos = new BlockPos(x, y, z);
|
||||
var x = Mth.floor(powderPos.x + level.random.nextGaussian() * range);
|
||||
var y = Mth.floor(powderPos.y + level.random.nextGaussian() * range);
|
||||
var z = Mth.floor(powderPos.z + level.random.nextGaussian() * range);
|
||||
var orePos = new BlockPos(x, y, z);
|
||||
if (orePos.distSqr(powderPos.x, powderPos.y, powderPos.z, true) <= range * range
|
||||
&& orePos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(orePos)) {
|
||||
BlockState state = level.getBlockState(orePos);
|
||||
var state = level.getBlockState(orePos);
|
||||
if (state.getBlock() != requiredBlock)
|
||||
continue;
|
||||
|
||||
outer:
|
||||
while (true) {
|
||||
WeightedOre ore = WeightedRandom.getRandomItem(level.random, ores, totalWeight).orElse(null);
|
||||
var ore = WeightedRandom.getRandomItem(level.random, ores, totalWeight).orElse(null);
|
||||
if (ore == null)
|
||||
continue;
|
||||
Tag<Block> tag = level.getTagManager().getOrEmpty(Registry.BLOCK_REGISTRY).getTag(ore.tag);
|
||||
var tag = level.getTagManager().getOrEmpty(Registry.BLOCK_REGISTRY).getTag(ore.tag);
|
||||
if (tag == null)
|
||||
continue;
|
||||
for (Block toPlace : tag.getValues()) {
|
||||
for (var toPlace : tag.getValues()) {
|
||||
if (toPlace == null || toPlace == Blocks.AIR)
|
||||
continue;
|
||||
|
||||
FakePlayer player = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
||||
var player = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
BlockHitResult ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false);
|
||||
BlockPlaceContext context = new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, ray));
|
||||
BlockState stateToPlace = toPlace.getStateForPlacement(context);
|
||||
var ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false);
|
||||
var context = new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, ray));
|
||||
var stateToPlace = toPlace.getStateForPlacement(context);
|
||||
if (SPAWN_EXCEPTIONS.contains(stateToPlace))
|
||||
continue;
|
||||
|
||||
level.setBlockAndUpdate(orePos, stateToPlace);
|
||||
level.levelEvent(2001, orePos, Block.getId(stateToPlace));
|
||||
|
||||
int toDrain = (20000 - ore.getWeight().asInt() * 2) * 2;
|
||||
BlockPos highestSpot = IAuraChunk.getHighestSpot(level, orePos, 30, pos);
|
||||
var toDrain = (20000 - ore.getWeight().asInt() * 2) * 2;
|
||||
var highestSpot = IAuraChunk.getHighestSpot(level, orePos, 30, pos);
|
||||
IAuraChunk.getAuraChunk(level, highestSpot).drainAura(highestSpot, toDrain);
|
||||
break outer;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
private boolean calcValues(Level level, BlockPos pos, Integer spot) {
|
||||
if (spot <= 0)
|
||||
return false;
|
||||
Pair<Integer, Integer> auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
var auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30);
|
||||
int aura = auraAndSpots.getLeft();
|
||||
if (aura < 1500000)
|
||||
return false;
|
||||
|
@ -63,16 +63,16 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (!this.calcValues(level, pos, spot))
|
||||
return;
|
||||
for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
int x = Mth.floor(pos.getX() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
int z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
BlockPos plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below();
|
||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
var x = Mth.floor(pos.getX() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
var z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
var plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below();
|
||||
if (plantPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(plantPos)) {
|
||||
if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, NAME))
|
||||
continue;
|
||||
|
||||
BlockState state = level.getBlockState(plantPos);
|
||||
Block block = state.getBlock();
|
||||
var state = level.getBlockState(plantPos);
|
||||
var block = state.getBlock();
|
||||
if (block instanceof BonemealableBlock growable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS_BLOCK) {
|
||||
if (growable.isValidBonemealTarget(level, plantPos, state, false)) {
|
||||
try {
|
||||
|
@ -81,7 +81,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
// a lot of stuff throws here (double plants where generation only caused half of it to exist, bamboo at level height...)
|
||||
// so just catch all, bleh
|
||||
}
|
||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, plantPos, 25, pos);
|
||||
var closestSpot = IAuraChunk.getHighestSpot(level, plantPos, 25, pos);
|
||||
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500);
|
||||
|
||||
PacketHandler.sendToAllAround(level, plantPos, 32,
|
||||
|
|
|
@ -25,18 +25,18 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
if (spot < 0) {
|
||||
List<ISpotDrainable> tiles = new ArrayList<>();
|
||||
Helper.getBlockEntitiesInArea(level, pos, 25, tile -> {
|
||||
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
var container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (container instanceof ISpotDrainable)
|
||||
tiles.add((ISpotDrainable) container);
|
||||
return false;
|
||||
});
|
||||
if (!tiles.isEmpty()) {
|
||||
IAuraType type = IAuraType.forLevel(level);
|
||||
for (int i = level.random.nextInt(6); i >= 0; i--) {
|
||||
ISpotDrainable tile = tiles.get(level.random.nextInt(tiles.size()));
|
||||
var type = IAuraType.forLevel(level);
|
||||
for (var i = level.random.nextInt(6); i >= 0; i--) {
|
||||
var tile = tiles.get(level.random.nextInt(tiles.size()));
|
||||
if (!tile.isAcceptableType(type))
|
||||
continue;
|
||||
int drained = tile.drainAuraPassively(-spot, false);
|
||||
var drained = tile.drainAuraPassively(-spot, false);
|
||||
if (drained <= 0)
|
||||
continue;
|
||||
auraChunk.storeAura(pos, drained);
|
||||
|
|
|
@ -19,16 +19,16 @@ public class SpreadEffect implements IDrainSpotEffect {
|
|||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(level, pos, 25)) < 2000000)
|
||||
return;
|
||||
boolean drain = spot > 0;
|
||||
int toMove = Mth.ceil(Math.abs(spot) * 0.72F);
|
||||
int perSide = toMove / 6;
|
||||
var drain = spot > 0;
|
||||
var toMove = Mth.ceil(Math.abs(spot) * 0.72F);
|
||||
var perSide = toMove / 6;
|
||||
while (toMove > 0) {
|
||||
BlockPos bestOffset = null;
|
||||
int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE;
|
||||
for (Direction facing : Direction.values()) {
|
||||
BlockPos offset = pos.relative(facing, 15);
|
||||
var bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE;
|
||||
for (var facing : Direction.values()) {
|
||||
var offset = pos.relative(facing, 15);
|
||||
if (level.isLoaded(offset) && offset.getY() >= 0 && offset.getY() <= level.getHeight()) {
|
||||
int amount = IAuraChunk.getAuraInArea(level, offset, 14);
|
||||
var amount = IAuraChunk.getAuraInArea(level, offset, 14);
|
||||
if (drain ? amount < bestAmount : amount > bestAmount) {
|
||||
bestAmount = amount;
|
||||
bestOffset = offset;
|
||||
|
@ -38,9 +38,9 @@ public class SpreadEffect implements IDrainSpotEffect {
|
|||
if (bestOffset == null)
|
||||
break;
|
||||
|
||||
BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(level, bestOffset, 14, bestOffset)
|
||||
var bestPos = drain ? IAuraChunk.getLowestSpot(level, bestOffset, 14, bestOffset)
|
||||
: IAuraChunk.getHighestSpot(level, bestOffset, 14, bestOffset);
|
||||
IAuraChunk bestChunk = IAuraChunk.getAuraChunk(level, bestPos);
|
||||
var bestChunk = IAuraChunk.getAuraChunk(level, bestPos);
|
||||
|
||||
int moved;
|
||||
if (drain) {
|
||||
|
|
|
@ -13,32 +13,32 @@ public final class CommandAura {
|
|||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
dispatcher.register(Commands.literal("naaura").requires(s -> s.hasPermission(2))
|
||||
.then(Commands.literal("add").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> {
|
||||
int amount = IntegerArgumentType.getInteger(context, "amount");
|
||||
CommandSourceStack source = context.getSource();
|
||||
BlockPos pos = new BlockPos(source.getPosition());
|
||||
var amount = IntegerArgumentType.getInteger(context, "amount");
|
||||
var source = context.getSource();
|
||||
var pos = new BlockPos(source.getPosition());
|
||||
while (amount > 0) {
|
||||
BlockPos spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos);
|
||||
var spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos);
|
||||
amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).storeAura(spot, amount);
|
||||
}
|
||||
source.sendSuccess(new TextComponent("Added aura to area"), true);
|
||||
return 0;
|
||||
})))
|
||||
.then(Commands.literal("remove").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> {
|
||||
int amount = IntegerArgumentType.getInteger(context, "amount");
|
||||
CommandSourceStack source = context.getSource();
|
||||
BlockPos pos = new BlockPos(source.getPosition());
|
||||
var amount = IntegerArgumentType.getInteger(context, "amount");
|
||||
var source = context.getSource();
|
||||
var pos = new BlockPos(source.getPosition());
|
||||
while (amount > 0) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos);
|
||||
var spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos);
|
||||
amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).drainAura(spot, amount);
|
||||
}
|
||||
source.sendSuccess(new TextComponent("Removed aura from area"), true);
|
||||
return 0;
|
||||
})))
|
||||
.then(Commands.literal("reset").executes(context -> {
|
||||
CommandSourceStack source = context.getSource();
|
||||
BlockPos pos = new BlockPos(source.getPosition());
|
||||
var source = context.getSource();
|
||||
var pos = new BlockPos(source.getPosition());
|
||||
IAuraChunk.getSpotsInArea(source.getLevel(), pos, 35, (spot, amount) -> {
|
||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(source.getLevel(), spot);
|
||||
var chunk = IAuraChunk.getAuraChunk(source.getLevel(), spot);
|
||||
if (amount > 0)
|
||||
chunk.drainAura(spot, amount);
|
||||
else
|
||||
|
|
|
@ -41,8 +41,8 @@ public final class Compat {
|
|||
}
|
||||
|
||||
private static void populateModules(Predicate<String> isLoaded) {
|
||||
for (Map.Entry<String, Supplier<ICompat>> entry : MODULE_TYPES.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
for (var entry : MODULE_TYPES.entrySet()) {
|
||||
var id = entry.getKey();
|
||||
if (isLoaded.test(id)) {
|
||||
MODULES.put(id, entry.getValue().get());
|
||||
NaturesAura.LOGGER.info("Loading compat module for mod " + id);
|
||||
|
|
|
@ -35,9 +35,9 @@ public class PatchouliCompat implements ICompat {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Recipe<?>> T getRecipe(String type, String name) {
|
||||
RecipeManager manager = Minecraft.getInstance().level.getRecipeManager();
|
||||
ResourceLocation res = new ResourceLocation(name);
|
||||
ResourceLocation pre = new ResourceLocation(res.getNamespace(), type + "/" + res.getPath());
|
||||
var manager = Minecraft.getInstance().level.getRecipeManager();
|
||||
var res = new ResourceLocation(name);
|
||||
var pre = new ResourceLocation(res.getNamespace(), type + "/" + res.getPath());
|
||||
return (T) manager.byKey(pre).orElse(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class BlockLootProvider implements DataProvider {
|
|||
public BlockLootProvider(DataGenerator generator) {
|
||||
this.generator = generator;
|
||||
|
||||
for (IModItem item : ModRegistry.ALL_ITEMS) {
|
||||
for (var item : ModRegistry.ALL_ITEMS) {
|
||||
if (!(item instanceof Block block))
|
||||
continue;
|
||||
if (block instanceof Slab) {
|
||||
|
@ -73,11 +73,11 @@ public class BlockLootProvider implements DataProvider {
|
|||
|
||||
@Override
|
||||
public void run(HashCache cache) throws IOException {
|
||||
for (Map.Entry<Block, Function<Block, LootTable.Builder>> function : this.lootFunctions.entrySet()) {
|
||||
Block block = function.getKey();
|
||||
Function<Block, LootTable.Builder> func = function.getValue();
|
||||
LootTable table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build();
|
||||
Path path = getPath(this.generator.getOutputFolder(), block.getRegistryName());
|
||||
for (var function : this.lootFunctions.entrySet()) {
|
||||
var block = function.getKey();
|
||||
var func = function.getValue();
|
||||
var table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build();
|
||||
var path = getPath(this.generator.getOutputFolder(), block.getRegistryName());
|
||||
DataProvider.save(GSON, cache, LootTables.serialize(table), path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class BlockStateGenerator extends BlockStateProvider {
|
|||
|
||||
@Override
|
||||
protected void registerStatesAndModels() {
|
||||
for (IModItem item : ModRegistry.ALL_ITEMS) {
|
||||
for (var item : ModRegistry.ALL_ITEMS) {
|
||||
if (!(item instanceof Block block))
|
||||
continue;
|
||||
if (block instanceof ICustomBlockState custom) {
|
||||
|
|
|
@ -19,8 +19,8 @@ public class ItemModelGenerator extends ItemModelProvider {
|
|||
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
for (IModItem modItem : ModRegistry.ALL_ITEMS) {
|
||||
String name = modItem.getBaseName();
|
||||
for (var modItem : ModRegistry.ALL_ITEMS) {
|
||||
var name = modItem.getBaseName();
|
||||
if (modItem instanceof ICustomItemModel) {
|
||||
((ICustomItemModel) modItem).generateCustomItemModel(this);
|
||||
} else if (modItem instanceof Item) {
|
||||
|
|
|
@ -11,9 +11,9 @@ public final class ModData {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void gatherData(GatherDataEvent event) {
|
||||
DataGenerator generator = event.getGenerator();
|
||||
ExistingFileHelper ex = event.getExistingFileHelper();
|
||||
BlockTagProvider blockTags = new BlockTagProvider(generator);
|
||||
var generator = event.getGenerator();
|
||||
var ex = event.getExistingFileHelper();
|
||||
var blockTags = new BlockTagProvider(generator);
|
||||
generator.addProvider(blockTags);
|
||||
generator.addProvider(new ItemTagProvider(generator, blockTags, ex));
|
||||
generator.addProvider(new BlockLootProvider(generator));
|
||||
|
|
|
@ -47,8 +47,8 @@ public class EntityLightProjectile extends ThrowableProjectile {
|
|||
protected void onHit(HitResult result) {
|
||||
if (!this.level.isClientSide) {
|
||||
if (result instanceof BlockHitResult res) {
|
||||
BlockPos pos = res.getBlockPos().relative(res.getDirection());
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
var pos = res.getBlockPos().relative(res.getDirection());
|
||||
var state = this.level.getBlockState(pos);
|
||||
if (state.getMaterial().isReplaceable())
|
||||
this.level.setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState());
|
||||
} else if (result instanceof EntityHitResult entity) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class EntityMoverMinecart extends AbstractMinecart {
|
|||
super.moveMinecartOnRail(railPos);
|
||||
if (!this.isActive)
|
||||
return;
|
||||
BlockPos pos = this.blockPosition();
|
||||
var pos = this.blockPosition();
|
||||
|
||||
if (!this.spotOffsets.isEmpty() && this.level.getGameTime() % 10 == 0)
|
||||
PacketHandler.sendToAllAround(this.level, pos, 32, new PacketParticles(
|
||||
|
@ -64,18 +64,18 @@ public class EntityMoverMinecart extends AbstractMinecart {
|
|||
}
|
||||
|
||||
private void moveAura(Level oldLevel, BlockPos oldPos, Level newLevel, BlockPos newPos) {
|
||||
for (BlockPos offset : this.spotOffsets) {
|
||||
BlockPos spot = oldPos.offset(offset);
|
||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(oldLevel, spot);
|
||||
int amount = chunk.getDrainSpot(spot);
|
||||
for (var offset : this.spotOffsets) {
|
||||
var spot = oldPos.offset(offset);
|
||||
var chunk = IAuraChunk.getAuraChunk(oldLevel, spot);
|
||||
var amount = chunk.getDrainSpot(spot);
|
||||
if (amount <= 0)
|
||||
continue;
|
||||
int toMove = Math.min(amount, 300000);
|
||||
int drained = chunk.drainAura(spot, toMove, false, false);
|
||||
var toMove = Math.min(amount, 300000);
|
||||
var drained = chunk.drainAura(spot, toMove, false, false);
|
||||
if (drained <= 0)
|
||||
continue;
|
||||
int toLose = Mth.ceil(drained / 250F);
|
||||
BlockPos newSpot = newPos.offset(offset);
|
||||
var toLose = Mth.ceil(drained / 250F);
|
||||
var newSpot = newPos.offset(offset);
|
||||
IAuraChunk.getAuraChunk(newLevel, newSpot).storeAura(newSpot, drained - toLose, false, false);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class EntityMoverMinecart extends AbstractMinecart {
|
|||
if (this.isActive != receivingPower) {
|
||||
this.isActive = receivingPower;
|
||||
|
||||
BlockPos pos = this.blockPosition();
|
||||
var pos = this.blockPosition();
|
||||
if (!this.isActive) {
|
||||
this.moveAura(this.level, this.lastPosition, this.level, pos);
|
||||
this.spotOffsets.clear();
|
||||
|
@ -110,12 +110,12 @@ public class EntityMoverMinecart extends AbstractMinecart {
|
|||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
CompoundTag compound = super.serializeNBT();
|
||||
var compound = super.serializeNBT();
|
||||
compound.putBoolean("active", this.isActive);
|
||||
compound.putLong("last_pos", this.lastPosition.asLong());
|
||||
|
||||
ListTag list = new ListTag();
|
||||
for (BlockPos offset : this.spotOffsets)
|
||||
var list = new ListTag();
|
||||
for (var offset : this.spotOffsets)
|
||||
list.add(LongTag.valueOf(offset.asLong()));
|
||||
compound.put("offsets", list);
|
||||
return compound;
|
||||
|
@ -128,17 +128,17 @@ public class EntityMoverMinecart extends AbstractMinecart {
|
|||
this.lastPosition = BlockPos.of(compound.getLong("last_pos"));
|
||||
|
||||
this.spotOffsets.clear();
|
||||
ListTag list = compound.getList("offsets", Tag.TAG_LONG);
|
||||
for (Tag base : list)
|
||||
var list = compound.getList("offsets", Tag.TAG_LONG);
|
||||
for (var base : list)
|
||||
this.spotOffsets.add(BlockPos.of(((LongTag) base).getAsLong()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(ServerLevel destination, ITeleporter teleporter) {
|
||||
Entity entity = super.changeDimension(destination, teleporter);
|
||||
var entity = super.changeDimension(destination, teleporter);
|
||||
if (entity instanceof EntityMoverMinecart) {
|
||||
BlockPos pos = entity.blockPosition();
|
||||
var pos = entity.blockPosition();
|
||||
this.moveAura(this.level, this.lastPosition, entity.level, pos);
|
||||
((EntityMoverMinecart) entity).lastPosition = pos;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public class EntityMoverMinecart extends AbstractMinecart {
|
|||
|
||||
@Override
|
||||
protected void applyNaturalSlowdown() {
|
||||
Vec3 motion = this.getDeltaMovement();
|
||||
var motion = this.getDeltaMovement();
|
||||
this.setDeltaMovement(motion.x * 0.99F, 0, motion.z * 0.99F);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ public class EntityStructureFinder extends EyeOfEnder {
|
|||
@Override
|
||||
public void signalTo(BlockPos pos) {
|
||||
double d0 = pos.getX();
|
||||
int i = pos.getY();
|
||||
var i = pos.getY();
|
||||
double d1 = pos.getZ();
|
||||
double d2 = d0 - this.getX();
|
||||
double d3 = d1 - this.getZ();
|
||||
var d2 = d0 - this.getX();
|
||||
var d3 = d1 - this.getZ();
|
||||
var f = Math.sqrt(d2 * d2 + d3 * d3);
|
||||
if (f > 12.0F) {
|
||||
this.targetX = this.getX() + d2 / (double) f * 12.0D;
|
||||
|
@ -75,10 +75,10 @@ public class EntityStructureFinder extends EyeOfEnder {
|
|||
public void tick() {
|
||||
this.baseTick();
|
||||
|
||||
Vec3 vec3d = this.getDeltaMovement();
|
||||
double d0 = this.getX() + vec3d.x;
|
||||
double d1 = this.getY() + vec3d.y;
|
||||
double d2 = this.getZ() + vec3d.z;
|
||||
var vec3d = this.getDeltaMovement();
|
||||
var d0 = this.getX() + vec3d.x;
|
||||
var d1 = this.getY() + vec3d.y;
|
||||
var d2 = this.getZ() + vec3d.z;
|
||||
var f = Math.sqrt(vec3d.horizontalDistance());
|
||||
this.setYRot((float) (Mth.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI)));
|
||||
this.setXRot((float) (Mth.atan2(vec3d.y, f) * (double) (180F / (float) Math.PI)));
|
||||
|
@ -93,24 +93,24 @@ public class EntityStructureFinder extends EyeOfEnder {
|
|||
this.setXRot(Mth.lerp(0.2F, this.xRotO, this.getXRot()));
|
||||
this.setYRot(Mth.lerp(0.2F, this.yRotO, this.getYRot()));
|
||||
if (!this.level.isClientSide) {
|
||||
double d3 = this.targetX - d0;
|
||||
double d4 = this.targetZ - d2;
|
||||
float f1 = (float) Math.sqrt(d3 * d3 + d4 * d4);
|
||||
float f2 = (float) Mth.atan2(d4, d3);
|
||||
double d5 = Mth.lerp(0.0025D, f, f1);
|
||||
double d6 = vec3d.y;
|
||||
var d3 = this.targetX - d0;
|
||||
var d4 = this.targetZ - d2;
|
||||
var f1 = (float) Math.sqrt(d3 * d3 + d4 * d4);
|
||||
var f2 = (float) Mth.atan2(d4, d3);
|
||||
var d5 = Mth.lerp(0.0025D, f, f1);
|
||||
var d6 = vec3d.y;
|
||||
if (f1 < 1.0F) {
|
||||
d5 *= 0.8D;
|
||||
d6 *= 0.8D;
|
||||
}
|
||||
|
||||
int j = this.getY() < this.targetY ? 1 : -1;
|
||||
var j = this.getY() < this.targetY ? 1 : -1;
|
||||
vec3d = new Vec3(Math.cos(f2) * d5, d6 + ((double) j - d6) * (double) 0.015F, Math.sin(f2) * d5);
|
||||
this.setDeltaMovement(vec3d);
|
||||
}
|
||||
|
||||
if (this.isInWater()) {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (var i = 0; i < 4; ++i)
|
||||
this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
|
||||
} else if (this.level.isClientSide) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(COLOR), 1, 50, 0, false, true);
|
||||
|
|
|
@ -37,12 +37,12 @@ public class RenderEffectInhibitor extends EntityRenderer<EntityEffectInhibitor>
|
|||
@Override
|
||||
public void render(EntityEffectInhibitor entity, float entityYaw, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
matrixStackIn.pushPose();
|
||||
float time = entity.renderTicks + entity.getId() + partialTicks;
|
||||
float bob = (float) Math.sin(time / 10F) * 0.05F;
|
||||
var time = entity.renderTicks + entity.getId() + partialTicks;
|
||||
var bob = (float) Math.sin(time / 10F) * 0.05F;
|
||||
matrixStackIn.translate(0, 0.15F + bob, 0);
|
||||
matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(time * 3 % 360));
|
||||
ResourceLocation effect = entity.getInhibitedEffect();
|
||||
ItemStack stack = this.items.computeIfAbsent(effect,
|
||||
var effect = entity.getInhibitedEffect();
|
||||
var stack = this.items.computeIfAbsent(effect,
|
||||
res -> ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), effect));
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn, 0);
|
||||
matrixStackIn.popPose();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue