mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Some more things....
This commit is contained in:
parent
f28b6714d4
commit
2e394d9230
5 changed files with 109 additions and 237 deletions
|
@ -144,7 +144,6 @@ public class ActuallyAdditions {
|
||||||
eventBus.addListener(ActuallyAdditionsClient::setupMenus);
|
eventBus.addListener(ActuallyAdditionsClient::setupMenus);
|
||||||
eventBus.addListener(ActuallyAdditionsClient::setupSpecialRenders);
|
eventBus.addListener(ActuallyAdditionsClient::setupSpecialRenders);
|
||||||
eventBus.addListener(ActuallyAdditionsClient::registerParticleFactories);
|
eventBus.addListener(ActuallyAdditionsClient::registerParticleFactories);
|
||||||
eventBus.register(new ClientRegistryHandler());
|
|
||||||
}
|
}
|
||||||
IFarmerBehavior.initBehaviors();
|
IFarmerBehavior.initBehaviors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package de.ellpeck.actuallyadditions.mod;
|
package de.ellpeck.actuallyadditions.mod;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
@ -29,10 +31,10 @@ public class ActuallyTabs {
|
||||||
.filter(stack -> stack.getItem() instanceof ItemEnergy).toList();
|
.filter(stack -> stack.getItem() instanceof ItemEnergy).toList();
|
||||||
charged.forEach(stack -> {
|
charged.forEach(stack -> {
|
||||||
if(stack.getItem() instanceof ItemEnergy itemEnergy) {
|
if(stack.getItem() instanceof ItemEnergy itemEnergy) {
|
||||||
// CustomEnergyStorage storage = new CustomEnergyStorage(itemEnergy.maxPower, itemEnergy.transfer, itemEnergy.transfer);
|
CustomEnergyStorage storage = new CustomEnergyStorage(itemEnergy.maxPower, itemEnergy.transfer, itemEnergy.transfer);
|
||||||
// storage.setEnergyStored(itemEnergy.maxPower);
|
storage.setEnergyStored(itemEnergy.maxPower);
|
||||||
// stack.setData(ActuallyComponents.ENERGY_STORAGE.get(), storage);
|
stack.set(ActuallyComponents.ENERGY_STORAGE.get(), storage);
|
||||||
// stack.getOrCreateTag().putBoolean("Charged", true); TODO: IMPORTANT: ADD BACK THE CREATIVE ITEMS!
|
stack.getOrCreateTag().putBoolean("Charged", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stacks.addAll(charged);
|
stacks.addAll(charged);
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
package de.ellpeck.actuallyadditions.mod;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.material.Fluid;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.client.event.ModelEvent.BakingCompleted;
|
|
||||||
import net.neoforged.neoforge.client.event.ModelEvent.RegisterGeometryLoaders;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: [port] eval all of this class
|
|
||||||
*/
|
|
||||||
public class ClientRegistryHandler {
|
|
||||||
|
|
||||||
public static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* (Excerpted from Tinkers' Construct with permission, thanks guys!)
|
|
||||||
*/
|
|
||||||
private static void registerCustomFluidBlockRenderer(Fluid fluid) {
|
|
||||||
// Block block = fluid.getBlock();
|
|
||||||
// Item item = Item.getItemFromBlock(block);
|
|
||||||
// FluidStateMapper mapper = new FluidStateMapper(fluid);
|
|
||||||
// ModelBakery.registerItemVariants(item);
|
|
||||||
// ModelLoader.setCustomMeshDefinition(item, mapper);
|
|
||||||
// ModelLoader.setCustomStateMapper(block, mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onModelRegistry(RegisterGeometryLoaders event) {
|
|
||||||
// for (Block block : RegistryHandler.BLOCKS_TO_REGISTER) {
|
|
||||||
// if (block instanceof IHasModel) {
|
|
||||||
// ((IHasModel) block).registerRendering();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (Map.Entry<ItemStack, ModelResourceLocation> entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()) {
|
|
||||||
// ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// registerCustomFluidBlockRenderer(InitFluids.fluidCanolaOil);
|
|
||||||
// registerCustomFluidBlockRenderer(InitFluids.fluidRefinedCanolaOil);
|
|
||||||
// registerCustomFluidBlockRenderer(InitFluids.fluidCrystalOil);
|
|
||||||
// registerCustomFluidBlockRenderer(InitFluids.fluidEmpoweredOil);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onModelBake(BakingCompleted e) {
|
|
||||||
// ModelResourceLocation mrl = new ModelResourceLocation(ActuallyAdditions.modLoc("block_compost"), "normal");
|
|
||||||
// CompostModel.compostBase = e.getModelRegistry().getObject(mrl);
|
|
||||||
// e.getModelRegistry().putObject(mrl, new ActualCompostModel());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
// TODO: [port] remove all of this
|
|
||||||
//package de.ellpeck.actuallyadditions.mod;
|
|
||||||
//
|
|
||||||
//import java.util.ArrayList;
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting;
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
|
||||||
//import de.ellpeck.actuallyadditions.mod.ore.InitOreDict;
|
|
||||||
//import net.minecraft.block.Block;
|
|
||||||
//import net.minecraft.item.Item;
|
|
||||||
//import net.minecraft.item.crafting.IRecipe;
|
|
||||||
//import net.minecraft.util.SoundEvent;
|
|
||||||
//import net.minecraftforge.event.RegistryEvent.Register;
|
|
||||||
//import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
//import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
|
||||||
//
|
|
||||||
////Class to wrap around the trainwreck that is the new registry system
|
|
||||||
//public class RegistryHandler {
|
|
||||||
//
|
|
||||||
// public static final List<Block> BLOCKS_TO_REGISTER = new ArrayList<>();
|
|
||||||
// public static final List<Item> ITEMS_TO_REGISTER = new ArrayList<>();
|
|
||||||
// public static final List<SoundEvent> SOUNDS_TO_REGISTER = new ArrayList<>();
|
|
||||||
// public static final List<IRecipe> RECIPES_TO_REGISTER = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void onBlockRegistry(Register<Block> event) {
|
|
||||||
// InitBlocks.init();
|
|
||||||
//
|
|
||||||
// for (Block block : BLOCKS_TO_REGISTER) {
|
|
||||||
// event.getRegistry().register(block);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void onItemRegistry(Register<Item> event) {
|
|
||||||
// InitItems.init();
|
|
||||||
//
|
|
||||||
// for (Item item : ITEMS_TO_REGISTER) {
|
|
||||||
// event.getRegistry().register(item);
|
|
||||||
// }
|
|
||||||
// ITEMS_TO_REGISTER.clear();
|
|
||||||
//
|
|
||||||
// //Hack to make this register before recipes :>
|
|
||||||
// InitOreDict.init();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void onVillagerRegistry(Register<VillagerProfession> event) {
|
|
||||||
// InitVillager.init();
|
|
||||||
//
|
|
||||||
// if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession);
|
|
||||||
// if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void onCraftingRegistry(Register<IRecipe> event) {
|
|
||||||
// InitCrafting.init();
|
|
||||||
//
|
|
||||||
// for (IRecipe recipe : RECIPES_TO_REGISTER) {
|
|
||||||
// event.getRegistry().register(recipe);
|
|
||||||
// }
|
|
||||||
// RECIPES_TO_REGISTER.clear();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void onSoundRegistry(Register<SoundEvent> event) {
|
|
||||||
// SoundHandler.init();
|
|
||||||
//
|
|
||||||
// for (SoundEvent sound : SOUNDS_TO_REGISTER) {
|
|
||||||
// event.getRegistry().register(sound);
|
|
||||||
// }
|
|
||||||
// SOUNDS_TO_REGISTER.clear();
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -13,8 +13,13 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
@ -24,6 +29,7 @@ import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
@ -60,13 +66,13 @@ public class Filler extends ItemEnergy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void saveData(BlockState state, ItemStack wand) {
|
private static void saveData(BlockState state, ItemStack wand) {
|
||||||
// wand.getOrCreateTag().put("state", NbtUtils.writeBlockState(state)); TODO: IMPORTANT: Fix Filler Item!
|
wand.getOrCreateTag().put("state", NbtUtils.writeBlockState(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<BlockState> loadData(ItemStack stack) {
|
private static Optional<BlockState> loadData(ItemStack stack) {
|
||||||
// if (stack.getOrCreateTag().contains("state")) {
|
if (stack.getOrCreateTag().contains("state")) {
|
||||||
// return Optional.of(NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), stack.getOrCreateTag().getCompound("state")));
|
return Optional.of(NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), stack.getOrCreateTag().getCompound("state")));
|
||||||
// }
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -84,16 +90,16 @@ public class Filler extends ItemEnergy {
|
||||||
saveData(state, stack);
|
saveData(state, stack);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else if (loadData(stack).isPresent()) {
|
} else if (loadData(stack).isPresent()) {
|
||||||
// CompoundTag compound = stack.getOrCreateTag();
|
CompoundTag compound = stack.getOrCreateTag();
|
||||||
//
|
|
||||||
// if (compound.getInt("CurrX") == 0 && compound.getInt("CurrY") == 0 && compound.getInt("CurrZ") == 0) {
|
if (compound.getInt("CurrX") == 0 && compound.getInt("CurrY") == 0 && compound.getInt("CurrZ") == 0) {
|
||||||
// compound.putInt("FirstX", context.getClickedPos().getX());
|
compound.putInt("FirstX", context.getClickedPos().getX());
|
||||||
// compound.putInt("FirstY", context.getClickedPos().getY());
|
compound.putInt("FirstY", context.getClickedPos().getY());
|
||||||
// compound.putInt("FirstZ", context.getClickedPos().getZ());
|
compound.putInt("FirstZ", context.getClickedPos().getZ());
|
||||||
//
|
|
||||||
// context.getPlayer().startUsingItem(context.getHand());
|
context.getPlayer().startUsingItem(context.getHand());
|
||||||
// return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.useOn(context);
|
return super.useOn(context);
|
||||||
|
@ -106,20 +112,20 @@ public class Filler extends ItemEnergy {
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
HitResult result = player.pick(Util.getReachDistance(player), 1f, false);
|
HitResult result = player.pick(Util.getReachDistance(player), 1f, false);
|
||||||
if (result instanceof BlockHitResult) {
|
if (result instanceof BlockHitResult) {
|
||||||
// CompoundTag compound = stack.getOrCreateTag();
|
CompoundTag compound = stack.getOrCreateTag();
|
||||||
//
|
|
||||||
// BlockPos pos = ((BlockHitResult) result).getBlockPos();
|
BlockPos pos = ((BlockHitResult) result).getBlockPos();
|
||||||
// compound.putInt("SecondX", pos.getX());
|
compound.putInt("SecondX", pos.getX());
|
||||||
// compound.putInt("SecondY", pos.getY());
|
compound.putInt("SecondY", pos.getY());
|
||||||
// compound.putInt("SecondZ", pos.getZ());
|
compound.putInt("SecondZ", pos.getZ());
|
||||||
//
|
|
||||||
// clear = false;
|
clear = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear) {
|
if (clear) {
|
||||||
// ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ");
|
ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ");
|
||||||
} //TODO: HOOK BACK UP!!!!!!!!!!!!!!!!!!!!!!!
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.releaseUsing(stack, world, entity, timeLeft);
|
super.releaseUsing(stack, world, entity, timeLeft);
|
||||||
|
@ -133,80 +139,80 @@ public class Filler extends ItemEnergy {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
boolean shouldClear = false;
|
boolean shouldClear = false;
|
||||||
|
|
||||||
// if (isSelected) {
|
if (isSelected) {
|
||||||
// if (entity instanceof Player player && stack.hasTag()) {
|
if (entity instanceof Player player && stack.hasTag()) {
|
||||||
// boolean creative = player.isCreative();
|
boolean creative = player.isCreative();
|
||||||
//
|
|
||||||
// CompoundTag compound = stack.getOrCreateTag();
|
|
||||||
//
|
|
||||||
// BlockPos firstPos = new BlockPos(compound.getInt("FirstX"), compound.getInt("FirstY"), compound.getInt("FirstZ"));
|
|
||||||
// BlockPos secondPos = new BlockPos(compound.getInt("SecondX"), compound.getInt("SecondY"), compound.getInt("SecondZ"));
|
|
||||||
//
|
|
||||||
// if (!BlockPos.ZERO.equals(firstPos) && !BlockPos.ZERO.equals(secondPos)) {
|
|
||||||
// int energyUse = 1500;
|
|
||||||
//
|
|
||||||
// Optional<BlockState> data = loadData(stack);
|
|
||||||
// if (data.isPresent() && (creative || this.getEnergyStored(stack) >= energyUse)) {
|
|
||||||
// BlockState replaceState = data.get(); // not the best way to do this.
|
|
||||||
// int lowestX = Math.min(firstPos.getX(), secondPos.getX());
|
|
||||||
// int lowestY = Math.min(firstPos.getY(), secondPos.getY());
|
|
||||||
// int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ());
|
|
||||||
//
|
|
||||||
// int currX = compound.getInt("CurrX");
|
|
||||||
// int currY = compound.getInt("CurrY");
|
|
||||||
// int currZ = compound.getInt("CurrZ");
|
|
||||||
//
|
|
||||||
// BlockPos pos = new BlockPos(lowestX + currX, lowestY + currY, lowestZ + currZ);
|
|
||||||
// BlockState state = world.getBlockState(pos);
|
|
||||||
//
|
|
||||||
// if (state.canBeReplaced() && replaceState.canSurvive(world, pos)) {
|
|
||||||
// if (creative || removeFittingItem(replaceState, player)) {
|
|
||||||
// world.setBlock(pos, replaceState, 2);
|
|
||||||
//
|
|
||||||
// SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, player);
|
|
||||||
// world.playSound(null, pos, sound.getPlaceSound(), SoundSource.BLOCKS, sound.getVolume() / 2F + .5F, sound.getPitch() * 0.8F);
|
|
||||||
//
|
|
||||||
// if (!creative) {
|
|
||||||
// this.extractEnergy(stack, energyUse, false);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// shouldClear = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int distX = Math.abs(secondPos.getX() - firstPos.getX());
|
|
||||||
// int distY = Math.abs(secondPos.getY() - firstPos.getY());
|
|
||||||
// int distZ = Math.abs(secondPos.getZ() - firstPos.getZ());
|
|
||||||
//
|
|
||||||
// currX++;
|
|
||||||
// if (currX > distX) {
|
|
||||||
// currX = 0;
|
|
||||||
// currY++;
|
|
||||||
// if (currY > distY) {
|
|
||||||
// currY = 0;
|
|
||||||
// currZ++;
|
|
||||||
// if (currZ > distZ) {
|
|
||||||
// shouldClear = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!shouldClear) {
|
|
||||||
// compound.putInt("CurrX", currX);
|
|
||||||
// compound.putInt("CurrY", currY);
|
|
||||||
// compound.putInt("CurrZ", currZ);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// shouldClear = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// shouldClear = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (shouldClear) { //TODO: HOOK BACK UP!!!!!!!!!!!!!!!!!!!!!!!
|
CompoundTag compound = stack.getOrCreateTag();
|
||||||
// ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ");
|
|
||||||
|
BlockPos firstPos = new BlockPos(compound.getInt("FirstX"), compound.getInt("FirstY"), compound.getInt("FirstZ"));
|
||||||
|
BlockPos secondPos = new BlockPos(compound.getInt("SecondX"), compound.getInt("SecondY"), compound.getInt("SecondZ"));
|
||||||
|
|
||||||
|
if (!BlockPos.ZERO.equals(firstPos) && !BlockPos.ZERO.equals(secondPos)) {
|
||||||
|
int energyUse = 1500;
|
||||||
|
|
||||||
|
Optional<BlockState> data = loadData(stack);
|
||||||
|
if (data.isPresent() && (creative || this.getEnergyStored(stack) >= energyUse)) {
|
||||||
|
BlockState replaceState = data.get(); // not the best way to do this.
|
||||||
|
int lowestX = Math.min(firstPos.getX(), secondPos.getX());
|
||||||
|
int lowestY = Math.min(firstPos.getY(), secondPos.getY());
|
||||||
|
int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ());
|
||||||
|
|
||||||
|
int currX = compound.getInt("CurrX");
|
||||||
|
int currY = compound.getInt("CurrY");
|
||||||
|
int currZ = compound.getInt("CurrZ");
|
||||||
|
|
||||||
|
BlockPos pos = new BlockPos(lowestX + currX, lowestY + currY, lowestZ + currZ);
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
|
if (state.canBeReplaced() && replaceState.canSurvive(world, pos)) {
|
||||||
|
if (creative || removeFittingItem(replaceState, player)) {
|
||||||
|
world.setBlock(pos, replaceState, 2);
|
||||||
|
|
||||||
|
SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, player);
|
||||||
|
world.playSound(null, pos, sound.getPlaceSound(), SoundSource.BLOCKS, sound.getVolume() / 2F + .5F, sound.getPitch() * 0.8F);
|
||||||
|
|
||||||
|
if (!creative) {
|
||||||
|
this.extractEnergy(stack, energyUse, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shouldClear = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int distX = Math.abs(secondPos.getX() - firstPos.getX());
|
||||||
|
int distY = Math.abs(secondPos.getY() - firstPos.getY());
|
||||||
|
int distZ = Math.abs(secondPos.getZ() - firstPos.getZ());
|
||||||
|
|
||||||
|
currX++;
|
||||||
|
if (currX > distX) {
|
||||||
|
currX = 0;
|
||||||
|
currY++;
|
||||||
|
if (currY > distY) {
|
||||||
|
currY = 0;
|
||||||
|
currZ++;
|
||||||
|
if (currZ > distZ) {
|
||||||
|
shouldClear = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldClear) {
|
||||||
|
compound.putInt("CurrX", currX);
|
||||||
|
compound.putInt("CurrY", currY);
|
||||||
|
compound.putInt("CurrZ", currZ);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shouldClear = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shouldClear = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldClear) {
|
||||||
|
ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue