Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e256a4f664 | |||
| 73cc3f8998 | |||
| 9c9a49f9e7 | |||
| 44c0931c02 | |||
| 874f46ed4d | |||
| b7949e4134 | |||
| ea95913ec8 | |||
| 423ab81813 | |||
| d82c713112 | |||
| 45cbc40177 | |||
| 33d7f02323 | |||
| 4e42b17e81 | |||
| 0e7e9313ee | |||
| 2bba843313 | |||
| a0949297d5 | |||
| 420fb272b4 | |||
| fc0f8eab56 | |||
| 41b7900706 | |||
| 7656157b0d |
+1
-1
@@ -23,7 +23,7 @@ kotlin_version=1.3.61
|
||||
fabric_kotlin_version=1.3.61+build.1
|
||||
|
||||
# Dependencies
|
||||
libblockattributes_version=0.8.0-pre.18
|
||||
libblockattributes_version=0.8.0-pre.19
|
||||
tr_energy_version=0.1.0
|
||||
|
||||
#########################################################
|
||||
|
||||
@@ -33,8 +33,8 @@ dependencies {
|
||||
compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api"
|
||||
|
||||
// Runtime, Mods
|
||||
// FIXME 1.16.2 runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}:${jei_version}")
|
||||
// FIXME 1.16.2 runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}:${jei_version}")
|
||||
runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
|
||||
//runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}")
|
||||
|
||||
// unit test dependencies
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.data.DataGenerator;
|
||||
import appeng.data.providers.loot.BlockDropProvider;
|
||||
import appeng.data.providers.recipes.SlabStairRecipes;
|
||||
import appeng.data.providers.tags.ConventionTagProvider;
|
||||
import appeng.data.providers.tags.ToolTagProviders;
|
||||
|
||||
public class Entrypoint implements PreLaunchEntrypoint {
|
||||
|
||||
@@ -21,6 +22,7 @@ public class Entrypoint implements PreLaunchEntrypoint {
|
||||
generator.install(new BlockDropProvider(output));
|
||||
generator.install(new SlabStairRecipes(output));
|
||||
generator.install(new ConventionTagProvider(output));
|
||||
generator.install(new ToolTagProviders(output));
|
||||
generator.run();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import appeng.core.AppEng;
|
||||
public class ConventionTagProvider extends TagProvider {
|
||||
|
||||
public ConventionTagProvider(Path outputPath) {
|
||||
super(outputPath);
|
||||
super("c", outputPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,15 +24,17 @@ import appeng.data.providers.IAE2DataProvider;
|
||||
public abstract class TagProvider implements IAE2DataProvider {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
protected static final String CONVENTION_NAMESPACE = "c";
|
||||
protected static final String TYPE_ITEMS = "items";
|
||||
protected static final String TYPE_BLOCKS = "blocks";
|
||||
|
||||
private final String defaultNamespace;
|
||||
|
||||
private final Path outputPath;
|
||||
|
||||
private DataCache cache;
|
||||
|
||||
protected TagProvider(Path outputPath) {
|
||||
protected TagProvider(String defaultNamespace, Path outputPath) {
|
||||
this.defaultNamespace = defaultNamespace;
|
||||
this.outputPath = outputPath;
|
||||
}
|
||||
|
||||
@@ -49,15 +51,19 @@ public abstract class TagProvider implements IAE2DataProvider {
|
||||
protected abstract void generate() throws IOException;
|
||||
|
||||
protected void addItemTag(String name, ItemConvertible... items) throws IOException {
|
||||
Identifier id = parseId(name);
|
||||
|
||||
List<String> itemIds = Arrays.stream(items).map(ItemConvertible::asItem).map(Registry.ITEM::getId)
|
||||
.map(Identifier::toString).collect(Collectors.toList());
|
||||
writeTagFile(CONVENTION_NAMESPACE, TYPE_ITEMS, name, itemIds);
|
||||
writeTagFile(id.getNamespace(), TYPE_ITEMS, id.getPath(), itemIds);
|
||||
}
|
||||
|
||||
protected void addBlockTag(String name, Block... blocks) throws IOException {
|
||||
Identifier id = parseId(name);
|
||||
|
||||
List<String> itemIds = Arrays.stream(blocks).map(Registry.BLOCK::getId).map(Identifier::toString)
|
||||
.collect(Collectors.toList());
|
||||
writeTagFile(CONVENTION_NAMESPACE, TYPE_BLOCKS, name, itemIds);
|
||||
writeTagFile(id.getNamespace(), TYPE_BLOCKS, id.getPath(), itemIds);
|
||||
}
|
||||
|
||||
protected void writeTagFile(String namespace, String tagType, String tagName, List<String> entries)
|
||||
@@ -75,7 +81,15 @@ public abstract class TagProvider implements IAE2DataProvider {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Convention Tags";
|
||||
return AppEng.MOD_NAME + " Tags (" + defaultNamespace + ")";
|
||||
}
|
||||
|
||||
private Identifier parseId(String name) {
|
||||
if (name.contains(":")) {
|
||||
return new Identifier(name);
|
||||
} else {
|
||||
return new Identifier(defaultNamespace, name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package appeng.data.providers.tags;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class ToolTagProviders extends TagProvider {
|
||||
|
||||
public ToolTagProviders(Path outputPath) {
|
||||
super("fabric", outputPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generate() throws IOException {
|
||||
addItemTag("axes", ITEMS.netherQuartzAxe(), ITEMS.certusQuartzAxe());
|
||||
addItemTag("hoes", ITEMS.netherQuartzHoe(), ITEMS.certusQuartzHoe());
|
||||
addItemTag("pickaxes", ITEMS.netherQuartzPick(), ITEMS.certusQuartzPick());
|
||||
addItemTag("shovels", ITEMS.netherQuartzShovel(), ITEMS.certusQuartzShovel());
|
||||
addItemTag("swords", ITEMS.netherQuartzSword(), ITEMS.certusQuartzSword());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Tool Tags";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public final class MEAttributes {
|
||||
return null;
|
||||
}
|
||||
|
||||
return attribute.getFirstOrNull(world, be.getPos().offset(side), SearchOptions.inDirection(side.getOpposite()));
|
||||
return attribute.getFirstOrNull(world, be.getPos(), SearchOptions.inDirection(side.getOpposite()));
|
||||
}
|
||||
|
||||
// Convenience function to get an attribute of the block that is in front of a
|
||||
|
||||
@@ -232,7 +232,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseBlockEntity> extends AEBas
|
||||
Platform.spawnDrops(world, pos, itemsToDrop);
|
||||
}
|
||||
|
||||
return ActionResult.FAIL;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof CableBusBlock)) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -19,6 +18,7 @@ import net.minecraft.util.registry.Registry;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.bootstrap.components.BlockEntityRendererComponent;
|
||||
import appeng.bootstrap.components.ITileEntityRegistrationComponent;
|
||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||
import appeng.core.AppEng;
|
||||
@@ -115,7 +115,8 @@ public class BlockEntityBuilder<T extends AEBaseBlockEntity> {
|
||||
@Environment(EnvType.CLIENT)
|
||||
private void buildClient() {
|
||||
if (tileEntityRendering.tileEntityRenderer != null) {
|
||||
BlockEntityRendererRegistry.INSTANCE.register(type, tileEntityRendering.tileEntityRenderer);
|
||||
factory.addBootstrapComponent(
|
||||
new BlockEntityRendererComponent<>(type, tileEntityRendering.tileEntityRenderer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.bootstrap.components;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
|
||||
/**
|
||||
* Registers a block entity renderer for a given block entity type. This must
|
||||
* occur late in the client's initialization, since the constructors of our
|
||||
* block entity renderers rely on the client being fully initialized.
|
||||
*/
|
||||
public class BlockEntityRendererComponent<T extends BlockEntity> implements IClientSetupComponent {
|
||||
|
||||
private final BlockEntityType<T> type;
|
||||
|
||||
private final Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> renderer;
|
||||
|
||||
public BlockEntityRendererComponent(BlockEntityType<T> type,
|
||||
Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> renderer) {
|
||||
this.type = type;
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
BlockEntityRendererRegistry.INSTANCE.register(type, renderer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
@@ -184,7 +185,9 @@ public final class AppEngClient extends AppEngBase {
|
||||
|
||||
ModelsReloadCallback.EVENT.register(this::onModelsReloaded);
|
||||
|
||||
callDeferredBootstrapComponents(IClientSetupComponent.class, IClientSetupComponent::setup);
|
||||
ClientLifecycleEvents.CLIENT_STARTED.register(client -> {
|
||||
callDeferredBootstrapComponents(IClientSetupComponent.class, IClientSetupComponent::setup);
|
||||
});
|
||||
registerModelProviders();
|
||||
registerParticleRenderers();
|
||||
registerEntityRenderers();
|
||||
|
||||
@@ -55,6 +55,7 @@ import appeng.hooks.BlockToolDispenseItemBehavior;
|
||||
import appeng.hooks.MatterCannonDispenseItemBehavior;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.items.misc.CrystalSeedItem;
|
||||
import appeng.items.misc.CrystalSeedRendering;
|
||||
import appeng.items.misc.EncodedPatternItem;
|
||||
import appeng.items.misc.PaintBallItem;
|
||||
import appeng.items.misc.PaintBallItemRendering;
|
||||
@@ -140,12 +141,12 @@ public final class ApiItems implements IItems {
|
||||
private final AEColoredItemDefinition coloredLumenPaintBall;
|
||||
|
||||
// unsupported dev tools
|
||||
private IItemDefinition toolEraser;
|
||||
private IItemDefinition toolMeteoritePlacer;
|
||||
private IItemDefinition toolDebugCard;
|
||||
private IItemDefinition toolReplicatorCard;
|
||||
private final IItemDefinition toolEraser;
|
||||
private final IItemDefinition toolMeteoritePlacer;
|
||||
private final IItemDefinition toolDebugCard;
|
||||
private final IItemDefinition toolReplicatorCard;
|
||||
|
||||
private IItemDefinition dummyFluidItem;
|
||||
private final IItemDefinition dummyFluidItem;
|
||||
|
||||
public ApiItems(FeatureFactory registry, ApiMaterials materials) {
|
||||
FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS);
|
||||
@@ -305,24 +306,15 @@ public final class ApiItems implements IItems {
|
||||
this.certusCrystalSeed = registry
|
||||
.item("certus_crystal_seed",
|
||||
props -> new CrystalSeedItem(props, materials.purifiedCertusQuartzCrystal().item()))
|
||||
.bootstrap(item -> new IClientSetupComponent() {
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void setup() {
|
||||
// Expose the growth of the seed to the model system
|
||||
FabricModelPredicateProviderRegistry.register(item, AppEng.makeId("growth"),
|
||||
(is, w, p) -> CrystalSeedItem.getGrowthTicks(is)
|
||||
/ (float) CrystalSeedItem.GROWTH_TICKS_REQUIRED);
|
||||
}
|
||||
}).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
this.fluixCrystalSeed = registry
|
||||
.item("fluix_crystal_seed",
|
||||
props -> new CrystalSeedItem(props, materials.purifiedFluixCrystal().item()))
|
||||
.features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
this.netherQuartzSeed = registry
|
||||
.item("nether_quartz_seed",
|
||||
props -> new CrystalSeedItem(props, materials.purifiedNetherQuartzCrystal().item()))
|
||||
.features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
|
||||
GrowingCrystalEntity.TYPE = registry
|
||||
.<GrowingCrystalEntity>entity("growing_crystal", GrowingCrystalEntity::new, SpawnGroup.MISC)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package appeng.items.misc;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
/**
|
||||
* Exposes a predicate "growth", which is used in the item model to
|
||||
* differentiate the growth stages.
|
||||
*/
|
||||
public class CrystalSeedRendering implements IClientSetupComponent {
|
||||
private final Item item;
|
||||
|
||||
public CrystalSeedRendering(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void setup() {
|
||||
// Expose the growth of the seed to the model system
|
||||
FabricModelPredicateProviderRegistry.register(item, AppEng.makeId("growth"),
|
||||
(is, w, p) -> CrystalSeedItem.getGrowthTicks(is) / (float) CrystalSeedItem.GROWTH_TICKS_REQUIRED);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
@@ -53,6 +54,7 @@ import appeng.core.sync.packets.ClickPacket;
|
||||
import appeng.hooks.AEToolItem;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.NetworkToolViewer;
|
||||
import appeng.util.PartHostWrenching;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench, AEToolItem {
|
||||
@@ -91,13 +93,17 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
|
||||
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart part = ((IPartHost) te).selectPart(mop.getPos());
|
||||
Vec3d relativePosition = mop.getPos().subtract(mop.getBlockPos().getX(), mop.getBlockPos().getY(),
|
||||
mop.getBlockPos().getZ());
|
||||
IPartHost host = (IPartHost) te;
|
||||
final SelectedPart part = host.selectPart(relativePosition);
|
||||
|
||||
if (part.part != null || part.facade != null) {
|
||||
if (part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo(mop)) {
|
||||
return ActionResult.FAIL;
|
||||
} else if (context.getPlayer().isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
PartHostWrenching.wrenchPart(context.getWorld(), context.getBlockPos(), host, part);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
} else if (te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo(mop)) {
|
||||
@@ -111,13 +117,6 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
// FIXME FABRIC: No direct equivalent
|
||||
// FIXME FABRIC: Might already be handled by onItemUseFirst though
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public boolean doesSneakBypassUse(ItemStack stack, WorldView world, BlockPos pos, PlayerEntity player) {
|
||||
// FIXME FABRIC return true;
|
||||
// FIXME FABRIC }
|
||||
|
||||
public boolean serverSideToolLogic(ItemUsageContext useContext) {
|
||||
BlockPos pos = useContext.getBlockPos();
|
||||
PlayerEntity p = useContext.getPlayer();
|
||||
|
||||
@@ -19,18 +19,27 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.hooks.AEToolItem;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.util.PartHostWrenching;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzWrenchItem extends AEBaseItem implements IAEWrench, AEToolItem {
|
||||
@@ -41,22 +50,58 @@ public class QuartzWrenchItem extends AEBaseItem implements IAEWrench, AEToolIte
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (!context.getPlayer().isInSneakingPose() && Platform
|
||||
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getBlockPos()), context.getPlayer())) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (player == null) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
Block block = context.getWorld().getBlockState(context.getBlockPos()).getBlock();
|
||||
if (block instanceof AEBaseBlock) {
|
||||
if (Platform.isClient()) {
|
||||
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server.
|
||||
// Fix that in all Block#onItemUseFirst overrides.
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.PASS;
|
||||
}
|
||||
boolean isHoldingShift = player.isInSneakingPose();
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getSide())) {
|
||||
context.getPlayer().swingHand(context.getHand());
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (isHoldingShift) {
|
||||
|
||||
// Wrenching parts of cable buses or other part hosts
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
IPartHost host = null;
|
||||
if (tile instanceof IPartHost) {
|
||||
host = (IPartHost) tile;
|
||||
}
|
||||
|
||||
if (host != null) {
|
||||
if (!world.isClient) {
|
||||
// Build the relative position within the part
|
||||
Vec3d relPos = context.getHitPos().subtract(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
final SelectedPart sp = PartPlacement.selectPart(player, host, relPos);
|
||||
|
||||
PartHostWrenching.wrenchPart(world, pos, host, sp);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
// Pass the use onto the block...
|
||||
return block.onUse(blockState, world, pos, player, context.getHand(),
|
||||
new BlockHitResult(context.getHitPos(), context.getSide(), pos, context.hitsInsideBlock()));
|
||||
}
|
||||
|
||||
if (block instanceof AEBaseBlock) {
|
||||
if (Platform.isClient()) {
|
||||
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server.
|
||||
// Fix that in all Block#onItemUseFirst overrides.
|
||||
return !world.isClient ? ActionResult.SUCCESS : ActionResult.PASS;
|
||||
}
|
||||
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(world, pos, context.getSide())) {
|
||||
player.swingHand(context.getHand());
|
||||
return !world.isClient ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
|
||||
@@ -176,7 +176,6 @@ public class Grid implements IGrid {
|
||||
}
|
||||
|
||||
gridNode.getGridProxy().gridChanged();
|
||||
// postEventTo( gridNode, networkChanged );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -502,7 +502,7 @@ public class EnergyGridCache implements IEnergyGrid {
|
||||
private void removeRequester(IAEPowerStorage requester) {
|
||||
Preconditions.checkState(!ongoingInjectOperation,
|
||||
"Cannot modify energy requesters while energy is being injected.");
|
||||
this.requesters.add(requester);
|
||||
this.requesters.remove(requester);
|
||||
}
|
||||
|
||||
private void addProvider(IAEPowerStorage provider) {
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -48,7 +45,6 @@ import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
@@ -85,56 +81,6 @@ public class PartPlacement {
|
||||
final BlockHitResult mop = world.rayTrace(rtc);
|
||||
ItemPlacementContext useContext = new ItemPlacementContext(new ItemUsageContext(player, hand, mop));
|
||||
|
||||
if (!held.isEmpty() && Platform.isWrench(player, held, pos) && player.isInSneakingPose()) {
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
final BlockEntity tile = world.getBlockEntity(pos);
|
||||
IPartHost host = null;
|
||||
|
||||
if (tile instanceof IPartHost) {
|
||||
host = (IPartHost) tile;
|
||||
}
|
||||
|
||||
if (host != null) {
|
||||
if (!world.isClient) {
|
||||
if (mop.getType() == HitResult.Type.BLOCK) {
|
||||
final List<ItemStack> is = new ArrayList<>();
|
||||
final SelectedPart sp = selectPart(player, host,
|
||||
mop.getPos().add(-mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ()));
|
||||
|
||||
if (sp.part != null) {
|
||||
is.add(sp.part.getItemStack(PartItemStack.WRENCH));
|
||||
sp.part.getDrops(is, true);
|
||||
host.removePart(sp.side, false);
|
||||
}
|
||||
|
||||
if (sp.facade != null) {
|
||||
is.add(sp.facade.getItemStack());
|
||||
host.getFacadeContainer().removeFacade(host, sp.side);
|
||||
Platform.notifyBlocksOfNeighbors(world, pos);
|
||||
}
|
||||
|
||||
if (host.isEmpty()) {
|
||||
host.cleanup();
|
||||
}
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
Platform.spawnDrops(world, pos, is);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.swingHand(hand);
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
IPartHost host = null;
|
||||
|
||||
@@ -178,6 +124,7 @@ public class PartPlacement {
|
||||
if (held.isEmpty()) {
|
||||
if (host != null && player.isInSneakingPose() && world.isAir(pos)) {
|
||||
if (mop.getType() == HitResult.Type.BLOCK) {
|
||||
// FIXME FABRIC: This looks wrong
|
||||
Vec3d hitVec = mop.getPos().add(-mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ());
|
||||
final SelectedPart sPart = selectPart(player, host, hitVec);
|
||||
if (sPart != null && sPart.part != null) {
|
||||
@@ -323,7 +270,7 @@ public class PartPlacement {
|
||||
return getEyeHeight();
|
||||
}
|
||||
|
||||
private static SelectedPart selectPart(final PlayerEntity player, final IPartHost host, final Vec3d pos) {
|
||||
public static SelectedPart selectPart(final PlayerEntity player, final IPartHost host, final Vec3d pos) {
|
||||
AppEng.instance().setPartInteractionPlayer(player);
|
||||
try {
|
||||
return host.selectPart(pos);
|
||||
@@ -401,8 +348,6 @@ public class PartPlacement {
|
||||
// FIXME FABRIC NetworkHandler.instance().sendToServer(new ClickPacket(event.getHand()));
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC } else if (event instanceof PlayerInteractEvent.RightClickBlock && !event.getPlayer().world.isClient) {
|
||||
// FIXME FABRIC
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC }
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
private final AppEngInternalInventory storageSlot = new AppEngInternalInventory(this, 1);
|
||||
// This is a FixedItemInv implementation to satisfy the UI, which is slot based
|
||||
private final CondenseItemHandler internalInputSlot = new CondenseItemHandler();
|
||||
private final CondenseItemInsertable externalItemInput = new CondenseItemInsertable();
|
||||
private final FluidInsertable externalFluidInput = new FluidHandler();
|
||||
private final MEHandler meHandler = new MEHandler();
|
||||
|
||||
@@ -215,16 +214,6 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
to.offer(meHandler);
|
||||
}
|
||||
|
||||
private class CondenseItemInsertable implements ItemInsertable {
|
||||
@Override
|
||||
public ItemStack attemptInsertion(ItemStack itemStack, Simulation simulation) {
|
||||
if (simulation == Simulation.ACTION && !itemStack.isEmpty()) {
|
||||
CondenserBlockEntity.this.addPower(itemStack.getCount());
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private class CondenseItemHandler implements FixedItemInv {
|
||||
@Override
|
||||
public int getSlotCount() {
|
||||
@@ -243,7 +232,7 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
|
||||
@Override
|
||||
public boolean setInvStack(int i, ItemStack itemStack, Simulation simulation) {
|
||||
if (simulation == Simulation.ACTION) {
|
||||
if (simulation == Simulation.ACTION && !itemStack.isEmpty()) {
|
||||
CondenserBlockEntity.this.addPower(itemStack.getCount());
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package appeng.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
|
||||
/**
|
||||
* Support functionality for using a wrench on parts attached to a part host.
|
||||
*/
|
||||
public final class PartHostWrenching {
|
||||
|
||||
private PartHostWrenching() {
|
||||
}
|
||||
|
||||
public static void wrenchPart(World world, BlockPos pos, IPartHost host, SelectedPart sp) {
|
||||
final List<ItemStack> is = new ArrayList<>();
|
||||
|
||||
if (sp.part != null) {
|
||||
is.add(sp.part.getItemStack(PartItemStack.WRENCH));
|
||||
sp.part.getDrops(is, true);
|
||||
host.removePart(sp.side, false);
|
||||
}
|
||||
|
||||
if (sp.facade != null) {
|
||||
is.add(sp.facade.getItemStack());
|
||||
host.getFacadeContainer().removeFacade(host, sp.side);
|
||||
Platform.notifyBlocksOfNeighbors(world, pos);
|
||||
}
|
||||
|
||||
if (host.isEmpty()) {
|
||||
host.cleanup();
|
||||
}
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
Platform.spawnDrops(world, pos, is);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user