mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
made the swamp homi not accept converted moss stone
This commit is contained in:
parent
040f48b612
commit
5e8e434925
4 changed files with 39 additions and 9 deletions
|
@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
|
import de.ellpeck.naturesaura.misc.WorldData;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -23,6 +25,7 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getGameTime() % 20 != 0)
|
if (this.world.getGameTime() % 20 != 0)
|
||||||
return;
|
return;
|
||||||
|
WorldData data = (WorldData) IWorldData.getWorldData(this.world);
|
||||||
|
|
||||||
List<BlockPos> possibleOffsets = new ArrayList<>();
|
List<BlockPos> possibleOffsets = new ArrayList<>();
|
||||||
int range = 2;
|
int range = 2;
|
||||||
|
@ -30,9 +33,15 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable
|
||||||
for (int y = -range; y <= range; y++)
|
for (int y = -range; y <= range; y++)
|
||||||
for (int z = -range; z <= range; z++) {
|
for (int z = -range; z <= range; z++) {
|
||||||
BlockPos offset = this.pos.add(x, y, z);
|
BlockPos offset = this.pos.add(x, y, z);
|
||||||
|
boolean isRecent = data.recentlyConvertedMossStones.contains(offset);
|
||||||
BlockState state = this.world.getBlockState(offset);
|
BlockState state = this.world.getBlockState(offset);
|
||||||
if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().containsKey(state))
|
if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().containsKey(state)) {
|
||||||
|
if (isRecent)
|
||||||
|
continue;
|
||||||
possibleOffsets.add(offset);
|
possibleOffsets.add(offset);
|
||||||
|
} else if (isRecent) {
|
||||||
|
data.recentlyConvertedMossStones.remove(offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (possibleOffsets.isEmpty())
|
if (possibleOffsets.isEmpty())
|
||||||
|
|
|
@ -3,7 +3,9 @@ package de.ellpeck.naturesaura.items.tools;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
|
import de.ellpeck.naturesaura.misc.WorldData;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
|
@ -14,7 +16,9 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.item.PickaxeItem;
|
import net.minecraft.item.PickaxeItem;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.ActionResultType;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
@ -46,10 +50,16 @@ public class Pickaxe extends PickaxeItem implements IModItem, IModelProvider {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
BlockState result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.get(state);
|
BlockState result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.get(state);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
if (!world.isRemote)
|
if (!world.isRemote) {
|
||||||
world.setBlockState(pos, result);
|
world.setBlockState(pos, result);
|
||||||
|
|
||||||
|
WorldData data = (WorldData) IWorldData.getWorldData(world);
|
||||||
|
data.recentlyConvertedMossStones.add(pos);
|
||||||
|
if (data.recentlyConvertedMossStones.size() > 512)
|
||||||
|
data.recentlyConvertedMossStones.remove(0);
|
||||||
|
}
|
||||||
world.playSound(player, pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
world.playSound(player, pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||||
stack.damageItem(15, player, playerEntity -> {});
|
stack.damageItem(15, player, playerEntity -> playerEntity.sendBreakAnimation(context.getHand()));
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class Shovel extends ShovelItem implements IModItem, IModelProvider {
|
||||||
|
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||||
stack.damageItem(damage, player, playerEntity -> {});
|
stack.damageItem(damage, player, playerEntity -> playerEntity.sendBreakAnimation(context.getHand()));
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,21 +11,24 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.INBT;
|
import net.minecraft.nbt.INBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
|
import net.minecraft.nbt.LongNBT;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class WorldData implements IWorldData {
|
public class WorldData implements IWorldData {
|
||||||
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
|
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
|
||||||
public final ListMultimap<ResourceLocation, Tuple<Vec3d, Integer>> effectPowders = ArrayListMultimap.create();
|
public final ListMultimap<ResourceLocation, Tuple<Vec3d, Integer>> effectPowders = ArrayListMultimap.create();
|
||||||
|
public final List<BlockPos> recentlyConvertedMossStones = new ArrayList<>();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,18 +51,26 @@ public class WorldData implements IWorldData {
|
||||||
}
|
}
|
||||||
compound.put("storages", storages);
|
compound.put("storages", storages);
|
||||||
|
|
||||||
|
ListNBT moss = new ListNBT();
|
||||||
|
for (BlockPos pos : this.recentlyConvertedMossStones)
|
||||||
|
moss.add(new LongNBT(pos.toLong()));
|
||||||
|
compound.put("converted_moss", moss);
|
||||||
|
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundNBT compound) {
|
public void deserializeNBT(CompoundNBT compound) {
|
||||||
this.enderStorages.clear();
|
this.enderStorages.clear();
|
||||||
ListNBT storages = compound.getList("storages", 10);
|
for (INBT base : compound.getList("storages", 10)) {
|
||||||
for (INBT base : storages) {
|
|
||||||
CompoundNBT storageComp = (CompoundNBT) base;
|
CompoundNBT storageComp = (CompoundNBT) base;
|
||||||
ItemStackHandlerNA storage = this.getEnderStorage(storageComp.getString("name"));
|
ItemStackHandlerNA storage = this.getEnderStorage(storageComp.getString("name"));
|
||||||
storage.deserializeNBT(storageComp);
|
storage.deserializeNBT(storageComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.recentlyConvertedMossStones.clear();
|
||||||
|
for (INBT base : compound.getList("converted_moss", Constants.NBT.TAG_LONG))
|
||||||
|
this.recentlyConvertedMossStones.add(BlockPos.fromLong(((LongNBT) base).getLong()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue