Lots more moved

This commit is contained in:
Sebastian Hartte
2020-07-04 21:03:30 +02:00
parent 5982f094ec
commit 1478e4c378
444 changed files with 4693 additions and 5235 deletions
+1
View File
@@ -39,6 +39,7 @@ repositories {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
compileJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
options.deprecation = false
}
// ensure everything uses UTF-8 and not some random codepage chosen by gradle
@@ -72,7 +72,7 @@ public interface IMovableRegistry {
* If you tile is handled with IMovableHandler or IMovableTile you do not need
* to white list it.
*/
void whiteListTileEntity(Class<? extends BlockEntity> c);
void whiteListBlockEntity(Class<? extends BlockEntity> c);
/**
* @param te to be moved block entity
@@ -0,0 +1,66 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.attributes;
import alexiil.mc.lib.attributes.Attribute;
import alexiil.mc.lib.attributes.Attributes;
import alexiil.mc.lib.attributes.SearchOptions;
import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.parts.AEBasePart;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
/**
* Utility class that holds various attributes, both by AE2 and other Mods.
*/
public final class MEAttributes {
private MEAttributes() {
}
public static Attribute<IStorageMonitorableAccessor> STORAGE_MONITORABLE_ACCESSOR
= Attributes.createDefaulted(IStorageMonitorableAccessor.class, new NullMENetworkAccessor());
public static <T> T getFirstAttributeOnSide(Attribute<T> attribute, BlockEntity be, Direction side) {
World world = be.getWorld();
if (world == null) {
return null;
}
return attribute.getFirstOrNull(world, be.getPos().offset(side), SearchOptions.inDirection(side.getOpposite()));
}
// Convenience function to get an attribute of the block that is in front of a part
public static <T> T getAttributeInFrontOfPart(Attribute<T> attribute, AEBasePart part) {
BlockEntity self = part.getHost().getTile();
Direction direction = part.getSide().getFacing();
final World w = self.getWorld();
BlockPos neighborPos = self.getPos().offset(direction);
// Do not force-load a neighboring chunk for this.
ChunkPos chunkPos = new ChunkPos(neighborPos);
if (!w.getChunkManager().isChunkLoaded(chunkPos.x, chunkPos.z)) {
return null;
}
return attribute.getFirstOrNull(w, neighborPos, SearchOptions.inDirection(direction));
}
}
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.capabilities;
package appeng.attributes;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable;
@@ -19,6 +19,7 @@
package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
@@ -32,13 +33,14 @@ public class CraftingStorageItem extends AEBaseBlockItem {
super(id, props);
}
@Override
public ItemStack getRecipeRemainder(final ItemStack itemStack) {
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
}
@Override
public boolean hasRecipeRemainder(final ItemStack stack) {
return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
}
// FIXME FABRIC needs to move to disassembly crafting recipes
// FIXME FABRIC @Override
// FIXME FABRIC public Item getRecipeRemainder() {
// FIXME FABRIC return AEApi.instance().definitions().blocks().craftingUnit().item();
// FIXME FABRIC }
// FIXME FABRIC
// FIXME FABRIC @Override
// FIXME FABRIC public boolean hasRecipeRemainder() {
// FIXME FABRIC return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
// FIXME FABRIC }
}
@@ -20,6 +20,7 @@ package appeng.block.grindstone;
import javax.annotation.Nullable;
import appeng.util.FakePlayer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
@@ -40,7 +41,6 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import appeng.api.implementations.tiles.ICrankable;
import appeng.block.AEBaseTileBlock;
@@ -57,7 +57,7 @@ public class CrankBlock extends AEBaseTileBlock<CrankBlockEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (player instanceof FakePlayer || player == null) {
if (FakePlayer.isFakePlayer(player) || player == null) {
this.dropCrank(w, pos);
return ActionResult.SUCCESS;
}
@@ -64,7 +64,7 @@ import appeng.util.Platform;
public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
public ChargerBlock() {
super(defaultProps(Material.METAL).solidBlock(false));
super(defaultProps(Material.METAL).solidBlock((state, world, pos) -> false));
}
@Override
@@ -158,8 +158,8 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
// FIXME FABRIC Hook does not exist
// FIXME FABRIC @Override
// FIXME FABRIC public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
// FIXME FABRIC boolean willHarvest, IFluidState fluid) {
// FIXME FABRIC if (player.abilities.isCreativeMode) {
// FIXME FABRIC boolean willHarvest, FluidState fluid) {
// FIXME FABRIC if (player.isCreative()) {
// FIXME FABRIC final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
// FIXME FABRIC if (tile != null) {
// FIXME FABRIC tile.disableDrops();
@@ -18,6 +18,7 @@
package appeng.block.networking;
import appeng.tile.networking.ControllerBlockEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
@@ -30,7 +31,6 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.ControllerBlockEntity;
public class ControllerBlock extends AEBaseTileBlock<ControllerBlockEntity> {
@@ -18,15 +18,13 @@
package appeng.block.networking;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.collection.DefaultedList;
import appeng.block.AEBaseTileBlock;
@@ -35,16 +33,15 @@ import appeng.tile.networking.EnergyCellBlockEntity;
public class EnergyCellBlock extends AEBaseTileBlock<EnergyCellBlockEntity> {
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create("fullness", 0, 7);
public static final IntProperty ENERGY_STORAGE = IntProperty.of("fullness", 0, 7);
public EnergyCellBlock() {
super(defaultProps(AEMaterials.GLASS));
}
@Override
@Environment(EnvType.CLIENT)
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemStacks) {
super.appendStacks(group, itemStacks);
public void addStacksForDisplay(ItemGroup group, DefaultedList<ItemStack> itemStacks) {
super.addStacksForDisplay(group, itemStacks);
final ItemStack charged = new ItemStack(this, 1);
final CompoundTag tag = charged.getOrCreateTag();
@@ -1,39 +1,40 @@
package appeng.block.paint;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.AppEng;
import appeng.helpers.Splotch;
import appeng.tile.misc.PaintSplotchesBlockEntity;
import com.google.common.collect.ImmutableList;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Renders paint blocks, which render multiple "splotches" that have been
* applied to the sides of adjacent blocks using a matter cannon with paint
* balls.
*/
class PaintSplotchesBakedModel implements IDynamicBakedModel {
class PaintSplotchesBakedModel implements BakedModel, FabricBakedModel {
private static final SpriteIdentifier TEXTURE_PAINT1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/paint1"));
@@ -49,30 +50,23 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
bakedTextureGetter.apply(TEXTURE_PAINT2), bakedTextureGetter.apply(TEXTURE_PAINT3) };
}
@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
@Nonnull IModelData extraData) {
public boolean isVanillaAdapter() {
return false;
}
if (side != null) {
return Collections.emptyList();
}
PaintSplotches splotchesState = extraData.getData(PaintSplotchesBlockEntity.SPLOTCHES);
if (splotchesState == null) {
// This is the inventory model which should usually not be used other than in
// special cases
List<BakedQuad> quads = new ArrayList<>(1);
CubeBuilder builder = new CubeBuilder(quads);
builder.setTexture(this.textures[0]);
builder.addCube(0, 0, 0, 16, 16, 16);
return quads;
@Override
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
Object renderAttachment = ((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos);
if (!(renderAttachment instanceof PaintSplotches)) {
return;
}
PaintSplotches splotchesState = (PaintSplotches) renderAttachment;
List<Splotch> splotches = splotchesState.getSplotches();
CubeBuilder builder = new CubeBuilder();
CubeBuilder builder = new CubeBuilder(context.getEmitter());
float offsetConstant = 0.001f;
for (final Splotch s : splotches) {
@@ -137,8 +131,15 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
default:
}
}
}
return builder.getOutput();
@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
}
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction face, Random random) {
return Collections.emptyList();
}
@Override
@@ -161,6 +162,11 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
return this.textures[0];
}
@Override
public ModelTransformation getTransformation() {
return null;
}
@Override
public ModelOverrideList getOverrides() {
return ModelOverrideList.EMPTY;
@@ -174,4 +180,5 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
static List<SpriteIdentifier> getRequiredTextures() {
return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
}
}
@@ -42,13 +42,12 @@ import appeng.util.Platform;
public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesBlockEntity> {
public PaintSplotchesBlock() {
super(defaultProps(Material.WATER, MaterialColor.CLEAR).notSolid());
super(defaultProps(Material.WATER, MaterialColor.CLEAR).solidBlock((state, world, pos) -> false)
.air());
}
@Override
@Environment(EnvType.CLIENT)
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemStacks) {
// do nothing
public void addStacksForDisplay(ItemGroup group, DefaultedList<ItemStack> list) {
}
@Override
@@ -67,35 +66,26 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesBlockEnti
}
@Override
public void fillWithRain(final World w, final BlockPos pos) {
public void rainTick(World world, BlockPos pos) {
if (Platform.isServer()) {
w.removeBlock(pos, false);
world.removeBlock(pos, false);
}
}
@Override
public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
final PaintSplotchesBlockEntity tp = this.getBlockEntity(w, pos);
// FIXME FABRIC currently no equivalent
// FIXME FABRIC @Override
// FIXME FABRIC public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
// FIXME FABRIC final PaintSplotchesBlockEntity tp = this.getBlockEntity(w, pos);
if (tp != null) {
return tp.getLightLevel();
}
// FIXME FABRIC if (tp != null) {
// FIXME FABRIC return tp.getLightLevel();
// FIXME FABRIC }
return 0;
}
// FIXME FABRIC return 0;
// FIXME FABRIC }
@Override
public boolean isAir(final BlockState state, final BlockView world, final BlockPos pos) {
return true;
}
@Override
public boolean isReplaceable(BlockState state, ItemPlacementContext useContext) {
return true;
}
@Override
public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) {
public boolean canReplace(BlockState state, ItemPlacementContext context) {
return true;
}
@@ -0,0 +1,36 @@
package appeng.block.paint;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.function.Function;
public class PaintSplotchesModel implements UnbakedModel {
@Nullable
@Override
public BakedModel bake(ModelLoader loader, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) {
return new PaintSplotchesBakedModel(textureGetter);
}
@Override
public Collection<SpriteIdentifier> getTextureDependencies(Function<Identifier, UnbakedModel> unbakedModelGetter, Set<Pair<String, String>> unresolvedTextureReferences) {
return PaintSplotchesBakedModel.getRequiredTextures();
}
@Override
public Collection<Identifier> getModelDependencies() {
return Collections.emptyList();
}
}
@@ -18,27 +18,19 @@
package appeng.block.spatial;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import appeng.block.AEBaseBlock;
import net.minecraft.block.*;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldView;
import net.minecraft.world.World;
import net.fabricmc.api.EnvType;
import appeng.block.AEBaseBlock;
import net.minecraft.world.WorldView;
import net.minecraft.world.explosion.Explosion;
/**
* This block is used to fill empty space in spatial dimensions and delinates
@@ -46,11 +38,10 @@ import appeng.block.AEBaseBlock;
*/
public class MatrixFrameBlock extends AEBaseBlock {
private static final Material MATERIAL = new Material(MaterialColor.CLEAR, false, true, true, false, false, false,
false, PistonBehavior.PUSH_ONLY);
private static final Material MATERIAL = new Material(MaterialColor.CLEAR, false, true, true, false, false, false, PistonBehavior.PUSH_ONLY);
public MatrixFrameBlock() {
super(Settings.create(MATERIAL).strength(-1.0F, 6000000.0F).notSolid().noDrops());
super(Settings.of(MATERIAL).strength(-1.0F, 6000000.0F).solidBlock((state, world, pos) -> false).dropsNothing());
}
@Override
@@ -59,8 +50,7 @@ public class MatrixFrameBlock extends AEBaseBlock {
}
@Override
@Environment(EnvType.CLIENT)
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemStacks) {
public void addStacksForDisplay(ItemGroup group, DefaultedList<ItemStack> list) {
// do nothing
}
@@ -82,8 +72,8 @@ public class MatrixFrameBlock extends AEBaseBlock {
}
@Override
public void onExplosionDestroy(final World world, final BlockPos pos, final Explosion explosion) {
// Don't explode.
public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
world.setBlockState(pos, getDefaultState(), 3);
}
@Override
@@ -92,13 +82,8 @@ public class MatrixFrameBlock extends AEBaseBlock {
}
@Override
public float getAmbientOcclusionLightValue(BlockState state, BlockView worldIn, BlockPos pos) {
public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
return 1.0f;
}
@Override
public boolean canEntityDestroy(final BlockState state, final BlockView world, final BlockPos pos,
final Entity entity) {
return false;
}
}
@@ -43,13 +43,14 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonBlockEntity>
}
}
@Override
public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
final SpatialPylonBlockEntity tsp = this.getBlockEntity(w, pos);
if (tsp != null) {
return tsp.getLightValue();
}
return super.getLightValue(state, w, pos);
}
// FIXME FABRIC Must use block states for dynamic lighting
// FIXME FABRIC @Override
// FIXME FABRIC public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
// FIXME FABRIC final SpatialPylonBlockEntity tsp = this.getBlockEntity(w, pos);
// FIXME FABRIC if (tsp != null) {
// FIXME FABRIC return tsp.getLightValue();
// FIXME FABRIC }
// FIXME FABRIC return super.getLightValue(state, w, pos);
// FIXME FABRIC }
}
@@ -20,6 +20,9 @@ package appeng.block.storage;
import javax.annotation.Nullable;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ChestContainer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
@@ -83,8 +86,8 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
p.sendSystemMessage(PlayerMessages.ChestCannotReadStorageCell.get(), Util.NIL_UUID);
}
} else {
// FIXME FABRIC ContainerOpener.openContainer(ChestContainer.TYPE, p,
// FIXME FABRIC ContainerLocator.forTileEntitySide(tg, hit.getSide()));
ContainerOpener.openContainer(ChestContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
throw new IllegalStateException();
}
+59 -8
View File
@@ -6,9 +6,12 @@ import appeng.bootstrap.components.IClientSetupComponent;
import appeng.bootstrap.components.IItemColorRegistrationComponent;
import appeng.bootstrap.components.IModelBakeComponent;
import appeng.bootstrap.components.ITileEntityRegistrationComponent;
import appeng.client.gui.implementations.*;
import appeng.client.render.cablebus.CableBusModelLoader;
import appeng.client.render.effects.*;
import appeng.client.render.tesr.InscriberTESR;
import appeng.client.render.tesr.SkyChestTESR;
import appeng.container.implementations.*;
import appeng.core.Api;
import appeng.core.ApiDefinitions;
import appeng.core.AppEng;
@@ -24,9 +27,12 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.render.entity.ItemEntityRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.util.InputUtil;
@@ -39,10 +45,7 @@ import net.minecraft.util.hit.HitResult;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -55,6 +58,8 @@ public final class AppEngClient extends AppEngBase {
private final ClientTickHandler tickHandler;
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>(ActionKey.class);
public static AppEngClient instance() {
return (AppEngClient) AppEng.instance();
}
@@ -75,6 +80,7 @@ public final class AppEngClient extends AppEngBase {
registerEntityRenderers();
registerItemColors();
registerTextures();
registerScreens();
// On the client, we'll register for server startup/shutdown to properly setup WorldData
// each time the integrated server starts&stops
@@ -153,8 +159,8 @@ public final class AppEngClient extends AppEngBase {
}
@Override
public boolean isActionKey(@Nonnull ActionKey key, InputUtil.Key input) {
return false;
public boolean isActionKey(@Nonnull ActionKey key, int keyCode, int scanCode) {
return this.bindings.get(key).matchesKey(keyCode, scanCode);
}
protected void registerParticleRenderers() {
@@ -194,9 +200,9 @@ public final class AppEngClient extends AppEngBase {
}
public void registerTextures() {
// FIXME FABRIC InscriberTESR.registerTexture();
Stream<Collection<SpriteIdentifier>> sprites = Stream.of(
SkyChestTESR.SPRITES
SkyChestTESR.SPRITES,
InscriberTESR.SPRITES
);
// Group every needed sprite by atlas, since every atlas has their own event
@@ -241,4 +247,49 @@ public final class AppEngClient extends AppEngBase {
// FIXME FABRIC new CableBusModelLoader());
}
private void registerScreens() {
ScreenRegistry.register(GrinderContainer.TYPE, GrinderScreen::new);
ScreenRegistry.register(QNBContainer.TYPE, QNBScreen::new);
ScreenRegistry.register(SkyChestContainer.TYPE, SkyChestScreen::new);
ScreenRegistry.register(ChestContainer.TYPE, ChestScreen::new);
ScreenRegistry.register(WirelessContainer.TYPE, WirelessScreen::new);
// FIXME FABRIC ScreenRegistry.<MEMonitorableContainer, MEMonitorableScreen<MEMonitorableContainer>>register(
// FIXME FABRIC MEMonitorableContainer.TYPE, MEMonitorableScreen::new);
// FIXME FABRIC ScreenRegistry.register(MEPortableCellContainer.TYPE, MEPortableCellScreen::new);
// FIXME FABRIC ScreenRegistry.register(WirelessTermContainer.TYPE, WirelessTermScreen::new);
// FIXME FABRIC ScreenRegistry.register(NetworkStatusContainer.TYPE, NetworkStatusScreen::new);
// FIXME FABRIC ScreenRegistry.<CraftingCPUContainer, CraftingCPUScreen<CraftingCPUContainer>>register(
// FIXME FABRIC CraftingCPUContainer.TYPE, CraftingCPUScreen::new);
// FIXME FABRIC ScreenRegistry.register(NetworkToolContainer.TYPE, NetworkToolScreen::new);
// FIXME FABRIC ScreenRegistry.register(QuartzKnifeContainer.TYPE, QuartzKnifeScreen::new);
// FIXME FABRIC ScreenRegistry.register(DriveContainer.TYPE, DriveScreen::new);
// FIXME FABRIC ScreenRegistry.register(VibrationChamberContainer.TYPE, VibrationChamberScreen::new);
// FIXME FABRIC ScreenRegistry.register(CondenserContainer.TYPE, CondenserScreen::new);
// FIXME FABRIC ScreenRegistry.register(InterfaceContainer.TYPE, InterfaceScreen::new);
// FIXME FABRIC ScreenRegistry.register(FluidInterfaceContainer.TYPE, FluidInterfaceScreen::new);
// FIXME FABRIC ScreenRegistry.<UpgradeableContainer, UpgradeableScreen<UpgradeableContainer>>register(
// FIXME FABRIC UpgradeableContainer.TYPE, UpgradeableScreen::new);
// FIXME FABRIC ScreenRegistry.register(FluidIOContainer.TYPE, FluidIOScreen::new);
// FIXME FABRIC ScreenRegistry.register(IOPortContainer.TYPE, IOPortScreen::new);
// FIXME FABRIC ScreenRegistry.register(StorageBusContainer.TYPE, StorageBusScreen::new);
// FIXME FABRIC ScreenRegistry.register(FluidStorageBusContainer.TYPE, FluidStorageBusScreen::new);
// FIXME FABRIC ScreenRegistry.register(FormationPlaneContainer.TYPE, FormationPlaneScreen::new);
// FIXME FABRIC ScreenRegistry.register(FluidFormationPlaneContainer.TYPE, FluidFormationPlaneScreen::new);
// FIXME FABRIC ScreenRegistry.register(PriorityContainer.TYPE, PriorityScreen::new);
// FIXME FABRIC ScreenRegistry.register(SecurityStationContainer.TYPE, SecurityStationScreen::new);
// FIXME FABRIC ScreenRegistry.register(CraftingTermContainer.TYPE, CraftingTermScreen::new);
// FIXME FABRIC ScreenRegistry.register(PatternTermContainer.TYPE, PatternTermScreen::new);
// FIXME FABRIC ScreenRegistry.register(FluidTerminalContainer.TYPE, FluidTerminalScreen::new);
// FIXME FABRIC ScreenRegistry.register(LevelEmitterContainer.TYPE, LevelEmitterScreen::new);
// FIXME FABRIC ScreenRegistry.register(FluidLevelEmitterContainer.TYPE, FluidLevelEmitterScreen::new);
// FIXME FABRIC ScreenRegistry.register(SpatialIOPortContainer.TYPE, SpatialIOPortScreen::new);
// FIXME FABRIC ScreenRegistry.register(InscriberContainer.TYPE, InscriberScreen::new);
// FIXME FABRIC ScreenRegistry.register(CellWorkbenchContainer.TYPE, CellWorkbenchScreen::new);
// FIXME FABRIC ScreenRegistry.register(MolecularAssemblerContainer.TYPE, MolecularAssemblerScreen::new);
// FIXME FABRIC ScreenRegistry.register(CraftAmountContainer.TYPE, CraftAmountScreen::new);
// FIXME FABRIC ScreenRegistry.register(CraftConfirmContainer.TYPE, CraftConfirmScreen::new);
// FIXME FABRIC ScreenRegistry.register(InterfaceTerminalContainer.TYPE, InterfaceTerminalScreen::new);
// FIXME FABRIC ScreenRegistry.register(CraftingStatusContainer.TYPE, CraftingStatusScreen::new);
}
}
@@ -22,8 +22,9 @@ import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Slot;
import net.minecraft.screen.slot.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -41,14 +42,14 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
}
@Override
protected void renderTooltip(final ItemStack stack, final int x, final int y) {
protected void renderTooltip(MatrixStack matrices, final ItemStack stack, final int x, final int y) {
final Slot s = this.getSlot(x, y);
if (s instanceof SlotME && !stack.isEmpty()) {
final int bigNumber = AEConfig.instance().isUseLargeFonts() ? 999 : 9999;
IAEItemStack myStack = null;
final List<String> currentToolTip = this.getTooltipFromItem(stack);
final List<Text> currentToolTip = this.getTooltipFromItem(stack);
try {
final SlotME theSlotField = (SlotME) s;
@@ -58,38 +59,31 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
if (myStack != null) {
if (myStack.getStackSize() > bigNumber || (myStack.getStackSize() > 1 && stack.isDamaged())) {
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
.format(myStack.getStackSize());
final String format = String.format(local, formattedAmount);
currentToolTip.add(Formatting.GRAY + format);
currentToolTip.add(ButtonToolTips.ItemsStored.text(formattedAmount)
.formatted(Formatting.GRAY));
}
if (myStack.getCountRequestable() > 0) {
final String local = ButtonToolTips.ItemsRequestable.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
.format(myStack.getCountRequestable());
final String format = String.format(local, formattedAmount);
currentToolTip.add(format);
currentToolTip.add(ButtonToolTips.ItemsRequestable.text(formattedAmount));
}
this.renderTooltip(currentToolTip, x, y, this.font);
this.renderTooltip(matrices, currentToolTip, x, y);
return;
} else if (stack.getCount() > bigNumber) {
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
final String format = String.format(local, formattedAmount);
currentToolTip.add(ButtonToolTips.ItemsStored.text(formattedAmount).formatted(Formatting.GRAY));
currentToolTip.add(Formatting.GRAY + format);
this.renderTooltip(currentToolTip, x, y, this.font);
this.renderTooltip(matrices, currentToolTip, x, y);
return;
}
}
super.renderTooltip(stack, x, y);
super.renderTooltip(matrices, stack, x, y);
}
}
@@ -25,38 +25,34 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import appeng.mixins.SlotMixin;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.StringRenderable;
import net.minecraft.text.Style;
import net.minecraft.util.Formatting;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.text.Text;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
@@ -88,7 +84,7 @@ import appeng.fluids.client.render.FluidStackSizeRenderer;
import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction;
public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerScreen<T> {
public abstract class AEBaseScreen<T extends AEBaseContainer> extends HandledScreen<T> {
private final List<InternalSlotME> meSlots = new ArrayList<>();
// drag y
private final Set<Slot> drag_click = new HashSet<>();
@@ -105,6 +101,18 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
super(container, playerInventory, title);
}
public MinecraftClient getClient() {
return Preconditions.checkNotNull(client);
}
public int getX() {
return x;
}
public int getY() {
return y;
}
@Override
public void init() {
super.init();
@@ -118,55 +126,55 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
private List<Slot> getInventorySlots() {
return this.container.inventorySlots;
return this.handler.slots;
}
@Override
public void render(final int mouseX, final int mouseY, final float partialTicks) {
super.renderBackground();
super.render(mouseX, mouseY, partialTicks);
public void render(MatrixStack matrices, final int mouseX, final int mouseY, final float partialTicks) {
super.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, partialTicks);
RenderSystem.pushMatrix();
RenderSystem.translatef(this.guiLeft, this.guiTop, 0.0F);
RenderSystem.translatef(this.x, this.y, 0.0F);
RenderSystem.enableDepthTest();
for (final CustomSlotWidget c : this.guiSlots) {
this.drawGuiSlot(c, mouseX, mouseY, partialTicks);
this.drawGuiSlot(matrices, c, mouseX, mouseY, partialTicks);
}
RenderSystem.disableDepthTest();
for (final CustomSlotWidget c : this.guiSlots) {
this.drawTooltip(c, mouseX - this.guiLeft, mouseY - this.guiTop);
this.drawTooltip(matrices, c, mouseX - this.x, mouseY - this.y);
}
RenderSystem.popMatrix();
RenderSystem.enableDepthTest();
this.renderHoveredToolTip(mouseX, mouseY);
this.drawMouseoverTooltip(matrices, mouseX, mouseY);
for (final Object c : this.buttons) {
if (c instanceof ITooltip) {
this.drawTooltip((ITooltip) c, mouseX, mouseY);
this.drawTooltip(matrices, (ITooltip) c, mouseX, mouseY);
}
}
}
protected void drawGuiSlot(CustomSlotWidget slot, int mouseX, int mouseY, float partialTicks) {
protected void drawGuiSlot(MatrixStack matrices, CustomSlotWidget slot, int mouseX, int mouseY, float partialTicks) {
if (slot.isSlotEnabled()) {
final int left = slot.xPos();
final int top = slot.yPos();
final int right = left + slot.getWidth();
final int bottom = top + slot.getHeight();
slot.drawContent(getMinecraft(), mouseX, mouseY, partialTicks);
slot.drawContent(getClient(), mouseX, mouseY, partialTicks);
if (this.isPointInRegion(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY)
if (this.isPointWithinBounds(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY)
&& slot.canClick(getPlayer())) {
RenderSystem.colorMask(true, true, true, false);
this.fillGradient(left, top, right, bottom, -2130706433, -2130706433);
this.fillGradient(matrices, left, top, right, bottom, -2130706433, -2130706433);
RenderSystem.colorMask(true, true, true, true);
}
}
}
private void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) {
private void drawTooltip(MatrixStack matrices, ITooltip tooltip, int mouseX, int mouseY) {
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
@@ -176,60 +184,61 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
y = 15;
}
final String msg = tooltip.getMessage();
final Text msg = tooltip.getMessage();
if (msg != null) {
this.drawTooltip(x + 11, y + 4, msg);
this.drawTooltip(matrices, x + 11, y + 4, msg);
}
}
}
}
protected void drawTooltip(int x, int y, String message) {
String[] lines = message.split("\n");
this.drawTooltip(x, y, Arrays.asList(lines));
protected void drawTooltip(MatrixStack matrices, int x, int y, Text message) {
String[] lines = message.getString().split("\n"); // FIXME FABRIC
this.drawTooltip(matrices, x, y, Arrays.asList(lines));
}
protected void drawTooltip(int x, int y, List<String> lines) {
// FIXME FABRIC: move out to json (?)
private static final Style TOOLTIP_HEADER = Style.EMPTY.withColor(Formatting.WHITE);
private static final Style TOOLTIP_BODY = Style.EMPTY.withColor(Formatting.GRAY);
protected void drawTooltip(MatrixStack matrices, int x, int y, List<String> lines) {
if (lines.isEmpty()) {
return;
}
// For an explanation of the formatting codes, see
// http://minecraft.gamepedia.com/Formatting_codes
lines = Lists.newArrayList(lines); // Make a copy
List<StringRenderable> renderableLines = new ArrayList<>(lines.size());
// Make the first line white
lines.set(0, Formatting.WHITE + lines.get(0));
// All lines after the first are colored gray
for (int i = 1; i < lines.size(); i++) {
lines.set(i, Formatting.GRAY + lines.get(i));
for (int i = 0; i < lines.size(); i++) {
Style style = (i == 0) ? TOOLTIP_HEADER : TOOLTIP_BODY;
renderableLines.add(StringRenderable.styled(lines.get(0), style));
}
this.renderTooltip(lines, x, y, this.font);
this.renderTooltip(matrices, renderableLines, x, y);
}
@Override
protected final void drawGuiContainerForegroundLayer(final int x, final int y) {
final int ox = this.guiLeft; // (width - xSize) / 2;
final int oy = this.guiTop; // (height - ySize) / 2;
protected final void drawForeground(MatrixStack matrices, final int x, final int y) {
final int ox = this.x; // (width - xSize) / 2;
final int oy = this.y; // (height - ySize) / 2;
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
if (this.getScrollBar() != null) {
this.getScrollBar().draw(this);
this.getScrollBar().draw(matrices, this);
}
this.drawFG(ox, oy, x, y);
this.drawFG(matrices, ox, oy, x, y);
}
public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY);
public abstract void drawFG(MatrixStack matrices, int offsetX, int offsetY, int mouseX, int mouseY);
@Override
protected final void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
final int ox = this.guiLeft; // (width - xSize) / 2;
final int oy = this.guiTop; // (height - ySize) / 2;
protected final void drawBackground(MatrixStack matrices, final float f, final int x, final int y) {
final int ox = this.x; // (width - xSize) / 2;
final int oy = this.y; // (height - ySize) / 2;
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawBG(ox, oy, x, y, f);
this.drawBG(matrices, ox, oy, x, y, f);
final List<Slot> slots = this.getInventorySlots();
for (final Slot slot : slots) {
@@ -238,13 +247,13 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (optionalSlot.isRenderDisabled()) {
final AppEngSlot aeSlot = (AppEngSlot) slot;
if (aeSlot.isSlotEnabled()) {
GuiUtils.drawTexturedModalRect(ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1,
optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18, 18, getBlitOffset());
drawTexture(matrices, ox + aeSlot.x - 1, oy + aeSlot.y - 1,
optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18, 18);
} else {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 0.4F);
RenderSystem.enableBlend();
GuiUtils.drawTexturedModalRect(ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1,
optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18, 18, getBlitOffset());
drawTexture(matrices, ox + aeSlot.x - 1, oy + aeSlot.y - 1,
optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18, 18);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
}
@@ -252,7 +261,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
for (final CustomSlotWidget slot : this.guiSlots) {
slot.drawBackground(ox, oy, getBlitOffset());
slot.drawBackground(ox, oy, getZOffset());
}
}
@@ -263,7 +272,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (btn == 1) {
for (final Object o : this.buttons) {
final Widget widget = (Widget) o;
final AbstractButtonWidget widget = (AbstractButtonWidget) o;
if (widget.isMouseOver(xCoord, yCoord)) {
return super.mouseClicked(xCoord, yCoord, 0);
}
@@ -271,14 +280,14 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
for (CustomSlotWidget slot : this.guiSlots) {
if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord)
if (this.isPointWithinBounds(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord)
&& slot.canClick(getPlayer())) {
slot.slotClicked(getPlayer().inventory.getItemStack(), btn);
slot.slotClicked(getPlayer().inventory.getCursorStack(), btn);
}
}
if (this.getScrollBar() != null) {
this.getScrollBar().click(xCoord - this.guiLeft, yCoord - this.guiTop);
this.getScrollBar().click(xCoord - this.x, yCoord - this.y);
}
return super.mouseClicked(xCoord, yCoord, btn);
@@ -288,11 +297,11 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
public boolean mouseDragged(double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
final Slot slot = this.getSlot((int) mouseX, (int) mouseY);
final ItemStack itemstack = getPlayer().inventory.getItemStack();
final ItemStack itemstack = getPlayer().inventory.getCursorStack();
if (this.getScrollBar() != null) {
// FIXME: Coordinate system of mouseX/mouseY is unclear
this.getScrollBar().click((int) mouseX - this.guiLeft, (int) mouseY - this.guiTop);
this.getScrollBar().click((int) mouseX - this.x, (int) mouseY - this.y);
}
if (slot instanceof FakeSlot && !itemstack.isEmpty()) {
@@ -301,7 +310,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
for (final Slot dr : this.drag_click) {
final InventoryActionPacket p = new InventoryActionPacket(
mouseButton == 0 ? InventoryAction.PICKUP_OR_SET_DOWN : InventoryAction.PLACE_SINGLE,
dr.slotNumber, 0);
dr.id, 0);
NetworkHandler.instance().sendToServer(p);
}
}
@@ -312,10 +321,10 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
}
// TODO 1.9.4 aftermath - Whole ClickType thing, to be checked.
// TODO 1.9.4 aftermath - Whole SlotActionType thing, to be checked.
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int mouseButton,
final ClickType clickType) {
protected void onMouseClick(final Slot slot, final int slotIdx, final int mouseButton,
final SlotActionType clickType) {
final PlayerEntity player = getPlayer();
if (slot instanceof FakeSlot) {
@@ -357,7 +366,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
return;
}
if (InputMappings.isKeyDown(MinecraftClient.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE)) {
if (InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_KEY_SPACE)) {
if (this.enableSpaceClicking()) {
IAEItemStack stack = null;
if (slot instanceof SlotME) {
@@ -367,10 +376,10 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
int slotNum = this.getInventorySlots().size();
if (!(slot instanceof SlotME) && slot != null) {
slotNum = slot.slotNumber;
slotNum = slot.id;
}
((AEBaseContainer) this.container).setTargetStack(stack);
this.handler.setTargetStack(stack);
final InventoryActionPacket p = new InventoryActionPacket(InventoryAction.MOVE_REGION, slotNum, 0);
NetworkHandler.instance().sendToServer(p);
return;
@@ -391,7 +400,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
case CLONE: // creative dupe:
if (player.abilities.isCreativeMode) {
if (player.isCreative()) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
@@ -402,7 +411,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
if (action != null) {
final InventoryActionPacket p = new InventoryActionPacket(action, slot.getSlotIndex(),
final InventoryActionPacket p = new InventoryActionPacket(action, getSlotIndex(slot),
((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance().sendToServer(p);
}
@@ -421,7 +430,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
stack = ((SlotME) slot).getAEStack();
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0
&& player.inventory.getItemStack().isEmpty()) {
&& player.inventory.getCursorStack().isEmpty()) {
action = InventoryAction.AUTO_CRAFT;
}
@@ -436,7 +445,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
stack = ((SlotME) slot).getAEStack();
if (stack != null && stack.isCraftable()) {
action = InventoryAction.AUTO_CRAFT;
} else if (player.abilities.isCreativeMode) {
} else if (player.isCreative()) {
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
if (slotItem != null) {
action = InventoryAction.CREATIVE_DUPLICATE;
@@ -449,7 +458,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
if (action != null) {
this.container.setTargetStack(stack);
this.handler.setTargetStack(stack);
final InventoryActionPacket p = new InventoryActionPacket(action, this.getInventorySlots().size(), 0);
NetworkHandler.instance().sendToServer(p);
}
@@ -466,7 +475,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
this.bl_clicked = slot;
this.dbl_clickTimer = Stopwatch.createStarted();
if (slot != null) {
this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
this.dbl_whichItem = slot.hasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
} else {
this.dbl_whichItem = ItemStack.EMPTY;
}
@@ -475,10 +484,10 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
final List<Slot> slots = this.getInventorySlots();
for (final Slot inventorySlot : slots) {
if (inventorySlot != null && inventorySlot.canTakeStack(getPlayer()) && inventorySlot.getHasStack()
&& inventorySlot.isSameInventory(slot)
&& Container.canAddItemToSlot(inventorySlot, this.dbl_whichItem, true)) {
this.handleMouseClick(inventorySlot, inventorySlot.slotNumber, 0, ClickType.QUICK_MOVE);
if (inventorySlot != null && inventorySlot.canTakeItems(getPlayer()) && inventorySlot.hasStack()
&& inventorySlot.inventory == slot.inventory
&& ScreenHandler.canInsertItemIntoSlot(inventorySlot, this.dbl_whichItem, true)) {
this.onMouseClick(inventorySlot, inventorySlot.id, 0, SlotActionType.QUICK_MOVE);
}
}
this.dbl_whichItem = ItemStack.EMPTY;
@@ -487,43 +496,43 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
this.disableShiftClick = false;
}
super.handleMouseClick(slot, slotIdx, mouseButton, clickType);
}
protected boolean func_195363_d(int keyCode, int scanCode) {
return checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode));
super.onMouseClick(slot, slotIdx, mouseButton, clickType);
}
protected ClientPlayerEntity getPlayer() {
// Our UIs are usually not opened when not in-game, so this should not be a
// problem
return Preconditions.checkNotNull(getMinecraft().player);
return Preconditions.checkNotNull(getClient().player);
}
protected boolean checkHotbarKeys(final InputUtil.Key input) {
final Slot theSlot = this.getSlotUnderMouse();
protected int getSlotIndex(Slot slot) {
return ((SlotMixin)slot).getIndex();
}
if (getPlayer().inventory.getItemStack().isEmpty() && theSlot != null) {
protected boolean checkHotbarKeys(int keyCode, int scanCode) {
final Slot theSlot = this.focusedSlot;
if (getPlayer().inventory.getCursorStack().isEmpty() && theSlot != null) {
for (int j = 0; j < 9; ++j) {
if (getMinecraft().options.keyBindsHotbar[j].isActiveAndMatches(input)) {
if (getClient().options.keysHotbar[j].matchesKey(keyCode, scanCode)) {
final List<Slot> slots = this.getInventorySlots();
for (final Slot s : slots) {
if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) {
if (!s.canTakeStack(((AEBaseContainer) this.container).getPlayerInv().player)) {
if (getSlotIndex(s) == j && s.inventory == this.handler.getPlayerInv()) {
if (!s.canTakeItems(this.handler.getPlayerInv().player)) {
return false;
}
}
}
if (theSlot.getSlotStackLimit() == 64) {
this.handleMouseClick(theSlot, theSlot.slotNumber, j, ClickType.SWAP);
if (theSlot.getMaxStackAmount() == 64) {
this.onMouseClick(theSlot, theSlot.id, j, SlotActionType.SWAP);
return true;
} else {
for (final Slot s : slots) {
if (s.getSlotIndex() == j
&& s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) {
if (getSlotIndex(s) == j
&& s.inventory == this.handler.getPlayerInv()) {
NetworkHandler.instance()
.sendToServer(new SwapSlotsPacket(s.slotNumber, theSlot.slotNumber));
.sendToServer(new SwapSlotsPacket(s.id, theSlot.id));
return true;
}
}
@@ -543,8 +552,8 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
protected Slot getSlot(final int mouseX, final int mouseY) {
final List<Slot> slots = this.getInventorySlots();
for (final Slot slot : slots) {
// isPointInRegion
if (this.isPointInRegion(slot.xPos, slot.yPos, 16, 16, mouseX, mouseY)) {
// isPointWithinBounds
if (this.isPointWithinBounds(slot.x, slot.y, 16, 16, mouseX, mouseY)) {
return slot;
}
}
@@ -552,7 +561,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
return null;
}
public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks);
public abstract void drawBG(MatrixStack matrices, int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks);
@Override
public boolean mouseScrolled(double x, double y, double wheelDelta) {
@@ -571,7 +580,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (slot instanceof SlotME) {
final IAEItemStack item = ((SlotME) slot).getAEStack();
if (item != null) {
((AEBaseContainer) this.container).setTargetStack(item);
this.handler.setTargetStack(item);
final InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP;
final int times = (int) Math.abs(wheel);
final int inventorySize = this.getInventorySlots().size();
@@ -589,18 +598,14 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
public void bindTexture(final String base, final String file) {
final Identifier loc = new Identifier(base, "textures/" + file);
getMinecraft().getTextureManager().bindTexture(loc);
getClient().getTextureManager().bindTexture(loc);
}
protected void drawItem(final int x, final int y, final ItemStack is) {
this.itemRenderer.zLevel = 100.0F;
this.itemRenderer.zOffset = 100.0F;
this.itemRenderer.renderInGuiWithOverrides(is, x, y);
// FIXME I dont think this is needed anymore...
RenderHelper.enableStandardItemLighting();
this.itemRenderer.renderItemAndEffectIntoGUI(is, x, y);
RenderHelper.disableStandardItemLighting();
this.itemRenderer.zLevel = 0.0F;
this.itemRenderer.zOffset = 0.0F;
}
protected String getGuiDisplayName(final String in) {
@@ -608,11 +613,11 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
private boolean hasCustomInventoryName() {
return this.container.getCustomName() != null;
return this.handler.getCustomName() != null;
}
private String getInventoryName() {
return this.container.getCustomName();
return this.handler.getCustomName();
}
/**
@@ -620,18 +625,18 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
* hackery...
*/
@Override
public void drawSlot(Slot s) {
public void drawSlot(MatrixStack matrices, Slot s) {
if (s instanceof SlotME) {
try {
if (!this.isPowered()) {
fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
fill(matrices, s.x, s.y, 16 + s.x, 16 + s.y, 0x66111111);
}
// Annoying but easier than trying to splice into render item
super.drawSlot(new Size1Slot((SlotME) s));
super.drawSlot(matrices, new Size1Slot((SlotME) s));
this.stackSizeRenderer.renderStackSize(this.font, ((SlotME) s).getAEStack(), s.xPos, s.yPos);
this.stackSizeRenderer.renderStackSize(this.textRenderer, ((SlotME) s).getAEStack(), s.x, s.y);
} catch (final Exception err) {
AELog.warn("[AppEng] AE prevented crash while drawing slot: " + err.toString());
@@ -643,27 +648,11 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
final IAEFluidStack fs = slot.getAEFluidStack();
if (fs != null && this.isPowered()) {
RenderSystem.disableBlend();
final Fluid fluid = fs.getFluid();
FluidAttributes fluidAttributes = fluid.getAttributes();
bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
Identifier fluidStillTexture = fluidAttributes.getStillTexture(fs.getFluidStack());
final Sprite sprite = getMinecraft()
.getAtlasSpriteGetter(SpriteAtlasTexture.BLOCK_ATLAS_TEX).apply(fluidStillTexture);
fs.getFluidStack().renderGuiRect(s.x, s.y, s.x + 16, s.y + 16);
// Set color for dynamic fluids
// Convert int color to RGB
float red = (fluidAttributes.getColor() >> 16 & 255) / 255.0F;
float green = (fluidAttributes.getColor() >> 8 & 255) / 255.0F;
float blue = (fluidAttributes.getColor() & 255) / 255.0F;
RenderSystem.color3f(red, green, blue);
blit(s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16, sprite);
RenderSystem.enableBlend();
this.fluidStackSizeRenderer.renderStackSize(this.font, fs, s.xPos, s.yPos);
this.fluidStackSizeRenderer.renderStackSize(this.textRenderer, fs, s.x, s.y);
} else if (!this.isPowered()) {
fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
fill(matrices, s.x, s.y, 16 + s.x, 16 + s.y, 0x66111111);
}
return;
@@ -684,28 +673,36 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
RenderSystem.enableTexture();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
final float par1 = aes.xPos;
final float par2 = aes.yPos;
final float par1 = aes.x;
final float par2 = aes.y;
final float par3 = uv_x * 16;
final float par4 = uv_y * 16;
final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder vb = tessellator.getBuffer();
vb.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEX_COLOR);
vb.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE);
final float f1 = 0.00390625F;
final float f = 0.00390625F;
final float par6 = 16;
vb.pos(par1 + 0, par2 + par6, getBlitOffset()).tex((par3 + 0) * f, (par4 + par6) * f1)
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex();
vb.vertex(par1 + 0, par2 + par6, getZOffset())
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon())
.texture((par3 + 0) * f, (par4 + par6) * f1)
.next();
final float par5 = 16;
vb.pos(par1 + par5, par2 + par6, getBlitOffset()).tex((par3 + par5) * f, (par4 + par6) * f1)
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex();
vb.pos(par1 + par5, par2 + 0, getBlitOffset()).tex((par3 + par5) * f, (par4 + 0) * f1)
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex();
vb.pos(par1 + 0, par2 + 0, getBlitOffset()).tex((par3 + 0) * f, (par4 + 0) * f1)
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex();
vb.vertex(par1 + par5, par2 + par6, getZOffset())
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon())
.texture((par3 + par5) * f, (par4 + par6) * f1)
.next();
vb.vertex(par1 + par5, par2 + 0, getZOffset())
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon())
.texture((par3 + par5) * f, (par4 + 0) * f1)
.next();
vb.vertex(par1 + 0, par2 + 0, getZOffset())
.color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon())
.texture((par3 + 0) * f, (par4 + 0) * f1)
.next();
tessellator.draw();
} catch (final Exception err) {
@@ -717,13 +714,13 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (!is.isEmpty() && s instanceof AppEngSlot) {
AppEngSlot aeSlot = (AppEngSlot) s;
if (aeSlot.getIsValid() == CalculatedValidity.NotAvailable) {
boolean isValid = s.isItemValid(is) || s instanceof OutputSlot
boolean isValid = s.canInsert(is) || s instanceof OutputSlot
|| s instanceof AppEngCraftingSlot || s instanceof DisabledSlot
|| s instanceof InaccessibleSlot || s instanceof FakeSlot
|| s instanceof RestrictedInputSlot || s instanceof SlotDisconnected;
if (isValid && s instanceof RestrictedInputSlot) {
try {
isValid = ((RestrictedInputSlot) s).isValid(is, getMinecraft().world);
isValid = ((RestrictedInputSlot) s).isValid(is, getClient().world);
} catch (final Exception err) {
AELog.debug(err);
}
@@ -732,21 +729,21 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
if (aeSlot.getIsValid() == CalculatedValidity.Invalid) {
setBlitOffset(100);
this.itemRenderer.zLevel = 100.0F;
setZOffset(100);
this.itemRenderer.zOffset = 100.0F;
fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666);
fill(matrices, s.x, s.y, 16 + s.x, 16 + s.y, 0x66ff6666);
setBlitOffset(0);
this.itemRenderer.zLevel = 0.0F;
setZOffset(0);
this.itemRenderer.zOffset = 0.0F;
}
}
if (s instanceof AppEngSlot) {
((AppEngSlot) s).setDisplay(true);
super.drawSlot(s);
super.drawSlot(matrices, s);
} else {
super.drawSlot(s);
super.drawSlot(matrices, s);
}
return;
@@ -755,7 +752,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
}
// do the usual for non-ME Slots.
super.drawSlot(s);
super.drawSlot(matrices, s);
}
protected boolean isPowered() {
@@ -764,11 +761,11 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
public void bindTexture(final String file) {
final Identifier loc = new Identifier(AppEng.MOD_ID, "textures/" + file);
getMinecraft().getTextureManager().bindTexture(loc);
getClient().getTextureManager().bindTexture(loc);
}
public void bindTexture(final Identifier loc) {
getMinecraft().getTextureManager().bindTexture(loc);
getClient().getTextureManager().bindTexture(loc);
}
protected Scrollbar getScrollBar() {
@@ -0,0 +1,81 @@
package appeng.client.gui;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.client.me.SlotME;
import com.mojang.datafixers.util.Pair;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.slot.Slot;
import net.minecraft.item.ItemStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.Identifier;
/**
* A proxy for a slot that will always return an itemstack with size 1, if there
* is an item in the slot. Used to prevent the default item count from
* rendering.
*/
class Size1Slot extends Slot {
private final SlotME delegate;
public Size1Slot(SlotME delegate) {
super(delegate.inventory, -1, delegate.x, delegate.y);
this.delegate = delegate;
}
@Override
@Nonnull
public ItemStack getStack() {
ItemStack orgStack = this.delegate.getStack();
if (!orgStack.isEmpty()) {
ItemStack modifiedStack = orgStack.copy();
modifiedStack.setCount(1);
return modifiedStack;
}
return ItemStack.EMPTY;
}
@Override
public boolean hasStack() {
return this.delegate.hasStack();
}
@Override
public int getMaxStackAmount() {
return this.delegate.getMaxStackAmount();
}
@Override
public int getMaxStackAmount(ItemStack stack) {
return this.delegate.getMaxStackAmount(stack);
}
@Override
public boolean canTakeItems(PlayerEntity playerIn) {
return this.delegate.canTakeItems(playerIn);
}
@Override
public void markDirty() {
delegate.markDirty();
}
@Override
@Environment(EnvType.CLIENT)
@Nullable
public Pair<Identifier, Identifier> getBackgroundSprite() {
return delegate.getBackgroundSprite();
}
@Override
@Environment(EnvType.CLIENT)
public boolean doDrawHoveringEffect() {
return delegate.doDrawHoveringEffect();
}
}
@@ -4,7 +4,7 @@ import java.util.function.Consumer;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.item.ItemStack;
@@ -26,6 +26,7 @@ import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.PatternTerminalPart;
import appeng.parts.reporting.TerminalPart;
import appeng.tile.storage.ChestBlockEntity;
import net.minecraft.text.Text;
/**
* Utility class for sub-screens of other containers that allow returning to the
@@ -92,13 +93,13 @@ final class AESubScreen {
return addBackButton(buttonAdder, x, y, null);
}
public final TabButton addBackButton(Consumer<TabButton> buttonAdder, int x, int y, @Nullable String label) {
public final TabButton addBackButton(Consumer<TabButton> buttonAdder, int x, int y, @Nullable Text label) {
if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) {
if (label == null) {
label = previousContainerIcon.getName().getString();
label = previousContainerIcon.getName();
}
ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer();
TabButton button = new TabButton(gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, label,
ItemRenderer itemRenderer = gui.getClient().getItemRenderer();
TabButton button = new TabButton(gui.getX() + x, gui.getY() + y, previousContainerIcon, label,
itemRenderer, btn -> goBack());
buttonAdder.accept(button);
return button;
@@ -18,9 +18,10 @@
package appeng.client.gui.implementations;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.widgets.TabButton;
@@ -34,14 +35,14 @@ public class ChestScreen extends AEBaseScreen<ChestContainer> {
public ChestScreen(ChestContainer container, PlayerInventory playerInventory, Text title) {
super(container, playerInventory, title);
this.ySize = 166;
this.backgroundHeight = 166;
}
@Override
public void init() {
super.init();
this.addButton(new TabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.textComponent(),
this.itemRenderer, btn -> openPriority()));
}
@@ -50,14 +51,14 @@ public class ChestScreen extends AEBaseScreen<ChestContainer> {
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752);
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
this.bindTexture("guis/chest.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
}
}
@@ -18,9 +18,10 @@
package appeng.client.gui.implementations;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import appeng.container.implementations.GrinderContainer;
@@ -30,18 +31,18 @@ public class GrinderScreen extends AEBaseScreen<GrinderContainer> {
public GrinderScreen(GrinderContainer container, PlayerInventory playerInventory, Text title) {
super(container, playerInventory, title);
this.ySize = 176;
this.backgroundHeight = 176;
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.GrindStone.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.GrindStone.getLocal()), 8, 6, 4210752);
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
this.bindTexture("guis/grinder.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
}
}
@@ -18,9 +18,10 @@
package appeng.client.gui.implementations;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import appeng.container.implementations.QNBContainer;
@@ -30,18 +31,18 @@ public class QNBScreen extends AEBaseScreen<QNBContainer> {
public QNBScreen(QNBContainer container, PlayerInventory playerInventory, Text title) {
super(container, playerInventory, title);
this.ySize = 166;
this.backgroundHeight = 166;
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.QuantumLinkChamber.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.QuantumLinkChamber.getLocal()), 8, 6, 4210752);
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
this.bindTexture("guis/chest.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
}
}
@@ -18,10 +18,11 @@
package appeng.client.gui.implementations;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.Identifier;
import net.minecraft.text.Text;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import appeng.container.implementations.SkyChestContainer;
@@ -34,19 +35,19 @@ public class SkyChestScreen extends AEBaseScreen<SkyChestContainer> {
public SkyChestScreen(SkyChestContainer container, PlayerInventory playerInv, Text title) {
super(container, playerInv, title);
this.ySize = 195;
this.backgroundHeight = 195;
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.SkyChest.getLocal()), 8, 8, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 2, 4210752);
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.SkyChest.getLocal()), 8, 8, 4210752);
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 2, 4210752);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
bindTexture(TEXTURE);
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0);
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
}
@Override
@@ -18,9 +18,10 @@
package appeng.client.gui.implementations;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.widgets.CommonButtons;
@@ -32,37 +33,37 @@ public class WirelessScreen extends AEBaseScreen<WirelessContainer> {
public WirelessScreen(WirelessContainer container, PlayerInventory playerInventory, Text title) {
super(container, playerInventory, title);
this.ySize = 166;
this.backgroundHeight = 166;
}
@Override
public void init() {
super.init();
this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8));
this.addButton(CommonButtons.togglePowerUnit(this.x - 18, this.y + 8));
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.Wireless.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Wireless.getLocal()), 8, 6, 4210752);
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752);
if (container.getRange() > 0) {
final String firstMessage = GuiText.Range.getLocal() + ": " + (container.getRange() / 10.0) + " m";
if (handler.getRange() > 0) {
final String firstMessage = GuiText.Range.getLocal() + ": " + (handler.getRange() / 10.0) + " m";
final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": "
+ Platform.formatPowerLong(container.getDrain(), true);
+ Platform.formatPowerLong(handler.getDrain(), true);
final int strWidth = Math.max(this.font.getStringWidth(firstMessage),
this.font.getStringWidth(secondMessage));
final int cOffset = (this.xSize / 2) - (strWidth / 2);
this.font.drawString(firstMessage, cOffset, 20, 4210752);
this.font.drawString(secondMessage, cOffset, 20 + 12, 4210752);
final int strWidth = Math.max(this.textRenderer.getWidth(firstMessage),
this.textRenderer.getWidth(secondMessage));
final int cOffset = (this.backgroundWidth / 2) - (strWidth / 2);
this.textRenderer.draw(matrices, firstMessage, cOffset, 20, 4210752);
this.textRenderer.draw(matrices, secondMessage, cOffset, 20 + 12, 4210752);
}
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
this.bindTexture("guis/wireless.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
}
}
@@ -21,11 +21,13 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
/**
* A modified version of the Minecraft text field. You can initialize it over
@@ -50,12 +52,12 @@ public class AETextField extends TextFieldWidget {
* @param width absolute width
* @param height absolute height
*/
public AETextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width,
final int height) {
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth('_'),
height - 2 * PADDING, "");
public AETextField(final TextRenderer fontRenderer, final int xPos, final int yPos, final int width,
final int height) {
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getWidth("_"),
height - 2 * PADDING, LiteralText.EMPTY);
this._fontPad = (int) fontRenderer.getCharWidth('_');
this._fontPad = (int) fontRenderer.getWidth("_");
}
@Override
@@ -66,15 +68,15 @@ public class AETextField extends TextFieldWidget {
final boolean requiresFocus = this.isMouseOver(xPos, yPos);
if (!this.isFocused()) {
this.setFocused2(requiresFocus);
this.setFocused(requiresFocus);
}
return true;
}
public void selectAll() {
this.setCursorPosition(0);
this.setSelectionPos(this.getMaxStringLength());
this.setCursor(0);
this.setSelectionEnd(getText().length());
}
public void setSelectionColor(int color) {
@@ -82,21 +84,21 @@ public class AETextField extends TextFieldWidget {
}
@Override
public void renderButton(int mouseX, int mouseY, float partial) {
if (this.getVisible()) {
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partial) {
if (this.isVisible()) {
if (this.isFocused()) {
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
fill(matrices, this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
this.y + this.height + PADDING - 1, 0xFF606060);
} else {
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
fill(matrices, this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
this.y + this.height + PADDING - 1, 0xFFA8A8A8);
}
super.renderButton(mouseX, mouseY, partial);
super.renderButton(matrices, mouseX, mouseY, partial);
}
}
@Override
public void drawSelectionBox(int startX, int startY, int endX, int endY) {
public void drawSelectionHighlight(int startX, int startY, int endX, int endY) {
if (!this.isFocused()) {
return;
}
@@ -139,14 +141,19 @@ public class AETextField extends TextFieldWidget {
RenderSystem.enableColorLogicOp();
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
bufferbuilder.begin(7, VertexFormats.POSITION);
bufferbuilder.pos(startX, endY, 0.0D).endVertex();
bufferbuilder.pos(endX, endY, 0.0D).endVertex();
bufferbuilder.pos(endX, startY, 0.0D).endVertex();
bufferbuilder.pos(startX, startY, 0.0D).endVertex();
bufferbuilder.vertex(startX, endY, 0.0D).next();
bufferbuilder.vertex(endX, endY, 0.0D).next();
bufferbuilder.vertex(endX, startY, 0.0D).next();
bufferbuilder.vertex(startX, startY, 0.0D).next();
tessellator.draw();
RenderSystem.disableColorLogicOp();
RenderSystem.enableTexture();
RenderSystem.color4f(1, 1, 1, 1);
}
@Override
public void setFocused(boolean focused) {
super.setFocused(focused);
}
}
@@ -23,6 +23,8 @@ import java.util.regex.Pattern;
import appeng.api.config.ActionItems;
import appeng.core.localization.ButtonToolTips;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
public class ActionButton extends IconButton implements ITooltip {
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
@@ -76,9 +78,9 @@ public class ActionButton extends IconButton implements ITooltip {
return iconIndex;
}
private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue) {
String name = displayName.getTranslationKey().getString();
String value = displayValue.getTranslationKey().getString();
private Text buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue) {
String name = displayName.text().getString();
String value = displayValue.text().getString();
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
final StringBuilder sb = new StringBuilder(value);
@@ -91,7 +93,7 @@ public class ActionButton extends IconButton implements ITooltip {
sb.replace(i, i + 1, "\n");
}
return name + '\n' + sb;
return new LiteralText(name + '\n' + sb);
}
}
@@ -2,11 +2,12 @@
package appeng.client.gui.widgets;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
public abstract class CustomSlotWidget extends DrawableHelper implements ITooltip {
private final int x;
private final int y;
private final int id;
@@ -34,7 +35,7 @@ public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
}
@Override
public String getMessage() {
public Text getMessage() {
return null;
}
@@ -18,6 +18,8 @@
package appeng.client.gui.widgets;
import net.minecraft.text.Text;
/**
* AEBaseGui controlled Tooltip Interface.
*/
@@ -28,7 +30,7 @@ public interface ITooltip {
*
* @return tooltip message
*/
String getMessage();
Text getMessage();
/**
* x Location for the object that triggers the tooltip.
@@ -21,19 +21,20 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier;
import net.minecraftforge.fml.client.gui.GuiUtils;
public abstract class IconButton extends Button implements ITooltip {
public abstract class IconButton extends ButtonWidget implements ITooltip {
public static final Identifier TEXTURE_STATES = new Identifier("appliedenergistics2",
"textures/guis/states.png");
private boolean halfSize = false;
public IconButton(final int x, final int y, IPressable onPress) {
super(x, y, 16, 16, "", onPress);
public IconButton(final int x, final int y, PressAction onPress) {
super(x, y, 16, 16, LiteralText.EMPTY, onPress);
}
public void setVisibility(final boolean vis) {
@@ -42,7 +43,7 @@ public abstract class IconButton extends Button implements ITooltip {
}
@Override
public void renderButton(final int mouseX, final int mouseY, float partial) {
public void renderButton(MatrixStack matrices, final int mouseX, final int mouseY, float partial) {
MinecraftClient minecraft = MinecraftClient.getInstance();
@@ -71,8 +72,8 @@ public abstract class IconButton extends Button implements ITooltip {
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
GuiUtils.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16, 0);
GuiUtils.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16, 0);
drawTexture(matrices, 0, 0, 256 - 16, 256 - 16, 16, 16);
drawTexture(matrices, 0, 0, uv_x * 16, uv_y * 16, 16, 16);
RenderSystem.popMatrix();
} else {
if (this.active) {
@@ -84,8 +85,8 @@ public abstract class IconButton extends Button implements ITooltip {
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0);
GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0);
drawTexture(matrices, this.x, this.y, 256 - 16, 256 - 16, 16, 16);
drawTexture(matrices, this.x, this.y, uv_x * 16, uv_y * 16, 16, 16);
}
RenderSystem.enableDepthTest();
}
@@ -18,24 +18,25 @@
package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.LiteralText;
// FIXME: Fix this piece of crap (i.e. onChange listener)
public class NumberBox extends TextFieldWidget {
private final Class type;
public NumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height,
final Class type) {
super(fontRenderer, x, y, width, height, "0");
public NumberBox(final TextRenderer fontRenderer, final int x, final int y, final int width, final int height,
final Class type) {
super(fontRenderer, x, y, width, height, new LiteralText("0"));
this.type = type;
}
@Override
public void writeText(final String selectedText) {
public void write(final String selectedText) {
final String original = this.getText();
super.writeText(selectedText);
super.write(selectedText);
try {
if (this.type == int.class || this.type == Integer.class) {
@@ -18,23 +18,24 @@
package appeng.client.gui.widgets;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.util.Identifier;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.container.interfaces.IProgressProvider;
import appeng.core.localization.GuiText;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class ProgressBar extends Widget implements ITooltip {
public class ProgressBar extends AbstractButtonWidget implements ITooltip {
private final IProgressProvider source;
private final Identifier texture;
private final int fill_u;
private final int fill_v;
private final Direction layout;
private final String titleName;
private String fullMsg;
private final Text titleName;
private Text fullMsg;
public ProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
final int u, final int y, final int width, final int height, final Direction dir) {
@@ -42,8 +43,8 @@ public class ProgressBar extends Widget implements ITooltip {
}
public ProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
final int u, final int y, final int width, final int height, final Direction dir, final String title) {
super(posX, posY, width, height, "");
final int u, final int y, final int width, final int height, final Direction dir, final Text title) {
super(posX, posY, width, height, LiteralText.EMPTY);
this.source = source;
this.texture = new Identifier("appliedenergistics2", "textures/" + texture);
this.fill_u = u;
@@ -53,7 +54,7 @@ public class ProgressBar extends Widget implements ITooltip {
}
@Override
public void renderButton(final int par2, final int par3, final float partial) {
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (this.visible) {
MinecraftClient.getInstance().getTextureManager().bindTexture(this.texture);
final int max = this.source.getMaxProgress();
@@ -61,28 +62,30 @@ public class ProgressBar extends Widget implements ITooltip {
if (this.layout == Direction.VERTICAL) {
final int diff = this.height - (max > 0 ? (this.height * current) / max : 0);
GuiUtils.drawTexturedModalRect(this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width,
this.height - diff, 0);
drawTexture(matrices, this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width,
this.height - diff);
} else {
final int diff = this.width - (max > 0 ? (this.width * current) / max : 0);
GuiUtils.drawTexturedModalRect(this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff,
this.height, 0);
drawTexture(matrices, this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff,
this.height);
}
}
}
public void setFullMsg(final String msg) {
public void setFullMsg(final Text msg) {
this.fullMsg = msg;
}
@Override
public String getMessage() {
public Text getMessage() {
if (this.fullMsg != null) {
return this.fullMsg;
}
return (this.titleName != null ? this.titleName : "") + '\n' + this.source.getCurrentProgress() + ' '
+ GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress();
Text text = this.titleName != null ? this.titleName : LiteralText.EMPTY;
return text.copy().append("\n" + this.source.getCurrentProgress() + " ")
.append(GuiText.Of.textComponent())
.append(" " + this.source.getMaxProgress());
}
@Override
@@ -20,9 +20,9 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
public class Scrollbar implements IScrollSource {
@@ -36,17 +36,18 @@ public class Scrollbar implements IScrollSource {
private int minScroll = 0;
private int currentScroll = 0;
public void draw(final AEBaseScreen<?> g) {
private final DrawableHelper drawable = new DrawableHelper(){};
public void draw(MatrixStack matrices, final AEBaseScreen<?> g) {
g.bindTexture("minecraft", "gui/container/creative_inventory/tabs.png");
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
drawable.setZOffset(g.getZOffset());
if (this.getRange() == 0) {
GuiUtils.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15,
g.getBlitOffset());
drawable.drawTexture(matrices, this.displayX, this.displayY, 232 + this.width, 0, this.width, 15);
} else {
final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
GuiUtils.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15,
g.getBlitOffset());
drawable.drawTexture(matrices, this.displayX, offset + this.displayY, 232, 0, this.width, 15);
}
}
@@ -25,7 +25,8 @@ import java.util.function.Predicate;
import java.util.regex.Pattern;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import appeng.api.config.AccessRestriction;
@@ -222,21 +223,21 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
}
}
private static void onPress(Button btn) {
private static void onPress(ButtonWidget btn) {
if (btn instanceof SettingToggleButton) {
((SettingToggleButton<?>) btn).triggerPress();
}
}
private void triggerPress() {
boolean backwards = MinecraftClient.getInstance().mouseHelper.isRightDown();
boolean backwards = MinecraftClient.getInstance().mouse.wasRightButtonClicked();
onPress.handle(this, backwards);
}
private static void registerApp(final int iconIndex, final Settings setting, final Enum<?> val,
final ButtonToolTips title, final Text hint) {
final ButtonAppearance a = new ButtonAppearance();
a.displayName = title.getTranslationKey();
a.displayName = title.text();
a.displayValue = hint;
a.index = iconIndex;
appearances.put(new EnumPair(setting, val), a);
@@ -244,7 +245,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
private static void registerApp(final int iconIndex, final Settings setting, final Enum<?> val,
final ButtonToolTips title, final ButtonToolTips hint) {
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
registerApp(iconIndex, setting, val, title, hint.text());
}
@Override
@@ -278,7 +279,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
}
@Override
public String getMessage() {
public Text getMessage() {
Text displayName = null;
Text displayValue = null;
@@ -286,7 +287,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
final ButtonAppearance buttonAppearance = appearances
.get(new EnumPair(this.buttonSetting, this.currentValue));
if (buttonAppearance == null) {
return "No Such Message";
return new LiteralText("No Such Message");
}
displayName = buttonAppearance.displayName;
@@ -312,7 +313,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
sb.replace(i, i + 1, "\n");
}
return name + '\n' + sb;
return new LiteralText(name + '\n' + sb);
}
return null;
}
@@ -21,13 +21,14 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class TabButton extends Button implements ITooltip {
public class TabButton extends ButtonWidget implements ITooltip {
public static final Identifier TEXTURE_STATES = new Identifier("appliedenergistics2",
"textures/guis/states.png");
private final ItemRenderer itemRenderer;
@@ -35,8 +36,8 @@ public class TabButton extends Button implements ITooltip {
private int myIcon = -1;
private ItemStack myItem;
public TabButton(final int x, final int y, final int ico, final String message, final ItemRenderer ir,
IPressable onPress) {
public TabButton(final int x, final int y, final int ico, final Text message, final ItemRenderer ir,
PressAction onPress) {
super(x, y, 22, 22, message, onPress);
this.myIcon = ico;
@@ -52,20 +53,20 @@ public class TabButton extends Button implements ITooltip {
* @param message mouse over message
* @param ir renderer
*/
public TabButton(final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir,
IPressable onPress) {
public TabButton(final int x, final int y, final ItemStack ico, final Text message, final ItemRenderer ir,
PressAction onPress) {
super(x, y, 22, 22, message, onPress);
this.myItem = ico;
this.itemRenderer = ir;
}
@Override
public void renderButton(final int x, final int y, float partial) {
public void renderButton(MatrixStack matrices, final int x, final int y, float partial) {
final MinecraftClient minecraft = MinecraftClient.getInstance();
if (this.visible) {
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
minecraft.textureManager.bindTexture(TEXTURE_STATES);
minecraft.getTextureManager().bindTexture(TEXTURE_STATES);
RenderSystem.enableAlphaTest();
@@ -73,25 +74,21 @@ public class TabButton extends Button implements ITooltip {
final int offsetX = this.hideEdge > 0 ? 1 : 0;
blit(this.x, this.y, uv_x * 16, 0, 25, 22);
drawTexture(matrices, this.x, this.y, uv_x * 16, 0, 25, 22);
if (this.myIcon >= 0) {
final int uv_y = this.myIcon / 16;
uv_x = this.myIcon - uv_y * 16;
blit(offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
drawTexture(matrices, offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
}
RenderSystem.disableAlphaTest();
if (this.myItem != null) {
this.itemRenderer.zLevel = 100.0F;
RenderHelper.enableStandardItemLighting();
this.itemRenderer.renderItemAndEffectIntoGUI(this.myItem, offsetX + this.x + 3, this.y + 3);
RenderHelper.disableStandardItemLighting();
this.itemRenderer.zLevel = 0.0F;
this.itemRenderer.zOffset = 100.0F;
this.itemRenderer.renderInGuiWithOverrides(this.myItem, offsetX + this.x + 3, this.y + 3);
this.itemRenderer.zOffset = 0.0F;
}
}
}
@@ -23,26 +23,27 @@ import java.util.regex.Pattern;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class ToggleButton extends Button implements ITooltip {
public class ToggleButton extends ButtonWidget implements ITooltip {
public static final Identifier TEXTURE_STATES = new Identifier("appliedenergistics2",
"textures/guis/states.png");
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
private final int iconIdxOn;
private final int iconIdxOff;
private final String displayName;
private final String displayHint;
private final Text displayName;
private final Text displayHint;
private boolean isActive;
public ToggleButton(final int x, final int y, final int on, final int off, final String displayName,
final String displayHint, IPressable onPress) {
super(x, y, 16, 16, "", onPress);
public ToggleButton(final int x, final int y, final int on, final int off, final Text displayName,
final Text displayHint, PressAction onPress) {
super(x, y, 16, 16, LiteralText.EMPTY, onPress);
this.iconIdxOn = on;
this.iconIdxOff = off;
this.displayName = displayName;
@@ -54,18 +55,18 @@ public class ToggleButton extends Button implements ITooltip {
}
@Override
public void renderButton(final int mouseX, final int mouseY, final float partial) {
public void renderButton(MatrixStack matrices, final int mouseX, final int mouseY, final float partial) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
MinecraftClient.getInstance().textureManager.bindTexture(TEXTURE_STATES);
MinecraftClient.getInstance().getTextureManager().bindTexture(TEXTURE_STATES);
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0);
GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0);
drawTexture(matrices, this.x, this.y, 256 - 16, 256 - 16, 16, 16);
drawTexture(matrices, this.x, this.y, uv_x * 16, uv_y * 16, 16, 16);
}
}
@@ -74,17 +75,10 @@ public class ToggleButton extends Button implements ITooltip {
}
@Override
public String getMessage() {
public Text getMessage() {
if (this.displayName != null) {
String name = I18n.format(this.displayName);
String value = I18n.format(this.displayHint);
if (name == null || name.isEmpty()) {
name = this.displayName;
}
if (value == null || value.isEmpty()) {
value = this.displayHint;
}
String name = this.displayName.getString();
String value = this.displayHint.getString();
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
final StringBuilder sb = new StringBuilder(value);
@@ -97,7 +91,7 @@ public class ToggleButton extends Button implements ITooltip {
sb.replace(i, i + 1, "\n");
}
return name + '\n' + sb;
return new LiteralText(name + '\n' + sb);
}
return null;
}
@@ -36,7 +36,7 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv> {
public ClientDCInternalInv(final int size, final long id, final long sortBy, final Text name) {
this.inventory = new AppEngInternalInventory(null, size);
this.searchName = name.getString().toLowerCase();
this.formattedName = name.getFormattedText();
this.formattedName = name.getString(); // FIXME FABRIC no longer formatted!
this.id = id;
this.sortBy = sortBy;
}
@@ -36,17 +36,17 @@ public class SlotDisconnected extends AppEngSlot {
}
@Override
public boolean isItemValid(final ItemStack par1ItemStack) {
public boolean canInsert(final ItemStack par1ItemStack) {
return false;
}
@Override
public void putStack(final ItemStack par1ItemStack) {
public void setStack(final ItemStack par1ItemStack) {
}
@Override
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
return false;
}
@@ -66,17 +66,17 @@ public class SlotDisconnected extends AppEngSlot {
}
@Override
public boolean getHasStack() {
public boolean hasStack() {
return !this.getStack().isEmpty();
}
@Override
public int getSlotStackLimit() {
public int getMaxStackAmount() {
return 0;
}
@Override
public ItemStack decrStackSize(final int par1) {
public ItemStack takeStack(final int par1) {
return ItemStack.EMPTY;
}
@@ -22,7 +22,7 @@ import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import net.minecraft.screen.slot.Slot;
import appeng.api.storage.data.IAEFluidStack;
import appeng.fluids.container.slots.IMEFluidSlot;
@@ -32,9 +32,9 @@ import appeng.fluids.container.slots.IMEFluidSlot;
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
public class SlotFluidME extends Slot implements IMEFluidSlot {
private InternalFluidSlotME slot;
private final InternalFluidSlotME slot;
public SlotFluidME(InternalFluidSlotME slot) {
super(null, 0, slot.getxPosition(), slot.getyPosition());
@@ -50,7 +50,7 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
}
@Override
public boolean isItemValid(final ItemStack par1ItemStack) {
public boolean canInsert(ItemStack stack) {
return false;
}
@@ -61,7 +61,7 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
}
@Override
public boolean getHasStack() {
public boolean hasStack() {
if (this.slot.hasPower()) {
return this.getAEFluidStack() != null;
}
@@ -69,23 +69,23 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
}
@Override
public void putStack(final ItemStack par1ItemStack) {
public void setStack(final ItemStack par1ItemStack) {
}
@Override
public int getSlotStackLimit() {
public int getMaxStackAmount() {
return 0;
}
@Nonnull
@Override
public ItemStack decrStackSize(final int par1) {
public ItemStack takeStack(final int par1) {
return ItemStack.EMPTY;
}
@Override
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
return false;
}
}
@@ -20,11 +20,11 @@ package appeng.client.me;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import net.minecraft.screen.slot.Slot;
import appeng.api.storage.data.IAEItemStack;
public class SlotME extends SlotItemHandler {
public class SlotME extends Slot {
private final InternalSlotME mySlot;
@@ -41,7 +41,7 @@ public class SlotME extends SlotItemHandler {
}
@Override
public boolean isItemValid(final ItemStack par1ItemStack) {
public boolean canInsert(ItemStack stack) {
return false;
}
@@ -54,7 +54,7 @@ public class SlotME extends SlotItemHandler {
}
@Override
public boolean getHasStack() {
public boolean hasStack() {
if (this.mySlot.hasPower()) {
return !this.getStack().isEmpty();
}
@@ -62,22 +62,21 @@ public class SlotME extends SlotItemHandler {
}
@Override
public void putStack(final ItemStack par1ItemStack) {
public void setStack(ItemStack stack) {
}
@Override
public int getSlotStackLimit() {
public int getMaxStackAmount() {
return 0;
}
@Override
public ItemStack decrStackSize(final int par1) {
public ItemStack takeStack(final int par1) {
return ItemStack.EMPTY;
}
@Override
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
return false;
}
}
@@ -20,10 +20,10 @@ package appeng.client.render;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.AffineTransformation;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.util.math.Vector3f;
import appeng.api.storage.data.IAEItemStack;
@@ -43,7 +43,7 @@ public class StackSizeRenderer {
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
public void renderStackSize(FontRenderer fontRenderer, IAEItemStack aeStack, int xPos, int yPos) {
public void renderStackSize(TextRenderer fontRenderer, IAEItemStack aeStack, int xPos, int yPos) {
if (aeStack != null) {
if (aeStack.getStackSize() == 0 && aeStack.isCraftable()) {
final String craftLabelText = AEConfig.instance().isUseLargeFonts() ? GuiText.LargeFontCraft.getLocal()
@@ -61,7 +61,7 @@ public class StackSizeRenderer {
}
}
public static void renderSizeLabel(FontRenderer fontRenderer, float xPos, float yPos, String text) {
public static void renderSizeLabel(TextRenderer fontRenderer, float xPos, float yPos, String text) {
final float scaleFactor = AEConfig.instance().isUseLargeFonts() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
@@ -72,12 +72,12 @@ public class StackSizeRenderer {
null, new Vector3f(scaleFactor, scaleFactor, scaleFactor), null);
RenderSystem.disableBlend();
final int X = (int) ((xPos + offset + 16.0f - fontRenderer.getStringWidth(text) * scaleFactor)
final int X = (int) ((xPos + offset + 16.0f - fontRenderer.getWidth(text) * scaleFactor)
* inverseScaleFactor);
final int Y = (int) ((yPos + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
VertexConsumerProvider.Impl buffer = VertexConsumerProvider.getImpl(Tessellator.getInstance().getBuffer());
fontRenderer.renderString(text, X, Y, 16777215, true, tm.getMatrix(), buffer, false, 0, 15728880);
buffer.finish();
VertexConsumerProvider.Immediate buffer = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
fontRenderer.draw(text, X, Y, 16777215, true, tm.getMatrix(), buffer, false, 0, 15728880);
buffer.draw();
RenderSystem.enableBlend();
}
@@ -19,13 +19,13 @@
package appeng.client.render;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
@@ -93,7 +93,7 @@ public class TesrRenderHelper {
matrixStack.scale(scale, scale, 0.0002f);
MinecraftClient.getInstance().getItemRenderer().renderItem(itemStack, ModelTransformation.Mode.GUI,
combinedLightIn, OverlayTexture.NO_OVERLAY, matrixStack, buffers);
combinedLightIn, OverlayTexture.DEFAULT_UV, matrixStack, buffers);
matrixStack.pop();
@@ -120,14 +120,14 @@ public class TesrRenderHelper {
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize);
// Render the item count
final FontRenderer fr = MinecraftClient.getInstance().fontRenderer;
final int width = fr.getStringWidth(renderedStackSize);
final TextRenderer fr = MinecraftClient.getInstance().textRenderer;
final int width = fr.getWidth(renderedStackSize);
matrixStack.push();
matrixStack.translate(0.0f, spacing, 0.02f);
matrixStack.scale(1.0f / 62.0f, -1.0f / 62.0f, 1.0f / 62.0f);
matrixStack.scale(0.5f, 0.5f, 0);
matrixStack.translate(-0.5f * width, 0.0f, 0.5f);
fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.peek().getMatrix(), buffers, false, 0,
fr.draw(renderedStackSize, 0, 0, -1, false, matrixStack.peek().getModel(), buffers, false, 0,
15728880);
matrixStack.pop();
@@ -63,7 +63,7 @@ public class CrankTESR extends BlockEntityRenderer<CrankBlockEntity> {
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
BakedModel model = dispatcher.getModel(blockState);
VertexConsumer buffer = buffers.getBuffer(TexturedRenderLayers.getEntityTranslucentCull());
dispatcher.getModelRenderer().renderModelBrightnessColor(ms.peek(), buffer, null, model, 1, 1, 1,
dispatcher.getModelRenderer().render(ms.peek(), buffer, null, model, 1, 1, 1,
combinedLightIn, combinedOverlayIn);
ms.pop();
@@ -8,8 +8,6 @@ import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.Vector3f;
@@ -61,8 +59,8 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
// Bottom Face
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
private static final RenderLayer STATE = RenderLayer.makeType("ae_drive_leds", VertexFormats.POSITION_COLOR, 7,
32565, false, true, RenderLayer.State.getBuilder().build(false));
private static final RenderLayer STATE = RenderLayer.of("ae_drive_leds", VertexFormats.POSITION_COLOR, 7,
32565, false, true, RenderLayer.MultiPhaseParameters.builder().build(false));
public DriveLedTileEntityRenderer(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
@@ -104,8 +102,8 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
float x = LED_QUADS[i];
float y = LED_QUADS[i + 1];
float z = LED_QUADS[i + 2];
buffer.pos(ms.peek().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
.endVertex();
buffer.vertex(ms.peek().getModel(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
.next();
}
ms.pop();
@@ -2,24 +2,27 @@
package appeng.client.render.tesr;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.item.Item;
import net.minecraft.tag.ItemTags;
import net.minecraft.tag.Tag;
import net.minecraft.util.math.Quaternion;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Identifier;
import net.minecraftforge.client.event.TextureStitchEvent;
import appeng.api.features.InscriberProcessType;
import appeng.client.render.FacingToRotation;
@@ -35,9 +38,13 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
private static final SpriteIdentifier TEXTURE_INSIDE = new SpriteIdentifier(PlayerContainer.LOCATION_BLOCKS_TEXTURE,
private static final SpriteIdentifier TEXTURE_INSIDE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/inscriber_inside"));
public static final ImmutableList<SpriteIdentifier> SPRITES = ImmutableList.of(
TEXTURE_INSIDE
);
public InscriberTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@@ -173,13 +180,13 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
private static void addVertex(VertexConsumer vb, MatrixStack ms, Sprite sprite, float x, float y,
float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) {
vb.pos(ms.peek().getMatrix(), x, y, z);
vb.vertex(ms.peek().getModel(), x, y, z);
vb.color(1.0f, 1.0f, 1.0f, 1.0f);
vb.tex(sprite.getFrameU(texU), sprite.getFrameV(texV));
vb.texture(sprite.getFrameU(texU), sprite.getFrameV(texV));
vb.overlay(overlayUV);
vb.lightmap(lightmapUV);
vb.light(lightmapUV);
vb.normal(ms.peek().getNormal(), front.getOffsetX(), front.getOffsetY(), front.getOffsetZ());
vb.endVertex();
vb.next();
}
private static final Identifier TAG_STORAGE_BLOCKS = new Identifier("forge:storage_blocks");
@@ -197,7 +204,8 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
// heuristic to scale items down much further than blocks
if (!stack.getItem().getTags().contains(TAG_STORAGE_BLOCKS)) {
Tag<Item> storageBlockTag = ItemTags.getContainer().get(TAG_STORAGE_BLOCKS);
if (storageBlockTag == null || !stack.getItem().isIn(storageBlockTag)) {
ms.scale(0.5f, 0.5f, 0.5f);
}
@@ -207,12 +215,6 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
}
}
public static void registerTexture(TextureStitchEvent.Pre evt) {
if (evt.getMap().getTextureLocation().equals(TEXTURE_INSIDE.getAtlasLocation())) {
evt.addSprite(TEXTURE_INSIDE.getTextureLocation());
}
}
// See https://easings.net/#easeOutBack
private static float easeCompressMotion(float x) {
float c1 = 1.70158f;
@@ -25,17 +25,18 @@ import java.util.HashSet;
import java.util.List;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import alexiil.mc.lib.attributes.item.compat.FixedInventoryVanillaWrapper;
import appeng.mixins.ScreenHandlerListeners;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.inventory.container.Slot;
import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -77,7 +78,7 @@ import appeng.util.inv.AdaptorFixedInv;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack;
public abstract class AEBaseContainer extends Container {
public abstract class AEBaseContainer extends ScreenHandler {
private final PlayerInventory invPlayer;
private final IActionSource mySrc;
private final HashSet<Integer> locked = new HashSet<>();
@@ -252,7 +253,7 @@ public abstract class AEBaseContainer extends Container {
return;
}
this.updateProgressBar(idx, (int) value);
this.setProperty(idx, (int) value);
}
public void stringSync(final int idx, final String value) {
@@ -261,8 +262,8 @@ public abstract class AEBaseContainer extends Container {
}
}
protected void bindPlayerInventory(final PlayerInventory PlayerInventory, final int offsetX, final int offsetY) {
FixedItemInv ih = new PlayerInvWrapper(PlayerInventory);
protected void bindPlayerInventory(final PlayerInventory playerInventory, final int offsetX, final int offsetY) {
FixedItemInv ih = new FixedInventoryVanillaWrapper(playerInventory);
// bind player inventory
for (int i = 0; i < 3; i++) {
@@ -297,8 +298,12 @@ public abstract class AEBaseContainer extends Container {
}
}
public List<ScreenHandlerListener> getListeners() {
return ((ScreenHandlerListeners)this).ae2_getListeners();
}
@Override
public void detectAndSendChanges() {
public void sendContentUpdates() {
this.sendCustomName();
if (Platform.isServer()) {
@@ -307,28 +312,28 @@ public abstract class AEBaseContainer extends Container {
this.setValidContainer(false);
}
for (final IContainerListener listener : this.listeners) {
for (final ScreenHandlerListener listener : this.getListeners()) {
for (final SyncData sd : this.syncData.values()) {
sd.tick(listener);
}
}
}
super.detectAndSendChanges();
super.sendContentUpdates();
}
@Override
public ItemStack transferStackInSlot(final PlayerEntity p, final int idx) {
public ItemStack transferSlot(final PlayerEntity p, final int idx) {
if (Platform.isClient()) {
return ItemStack.EMPTY;
}
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
final AppEngSlot clickSlot = (AppEngSlot) this.slots.get(idx); // require AE SLots!
if (clickSlot instanceof DisabledSlot || clickSlot instanceof InaccessibleSlot) {
return ItemStack.EMPTY;
}
if (clickSlot != null && clickSlot.getHasStack()) {
if (clickSlot != null && clickSlot.hasStack()) {
ItemStack tis = clickSlot.getStack();
if (tis.isEmpty()) {
@@ -345,11 +350,11 @@ public abstract class AEBaseContainer extends Container {
if (!tis.isEmpty()) {
// target slots in the container...
for (final Object inventorySlot : this.inventorySlots) {
for (final Object inventorySlot : this.slots) {
final AppEngSlot cs = (AppEngSlot) inventorySlot;
if (!(cs.isPlayerSide()) && !(cs instanceof FakeSlot) && !(cs instanceof CraftingMatrixSlot)) {
if (cs.isItemValid(tis)) {
if (cs.canInsert(tis)) {
selectedSlots.add(cs);
}
}
@@ -359,11 +364,11 @@ public abstract class AEBaseContainer extends Container {
tis = tis.copy();
// target slots in the container...
for (final Object inventorySlot : this.inventorySlots) {
for (final Object inventorySlot : this.slots) {
final AppEngSlot cs = (AppEngSlot) inventorySlot;
if ((cs.isPlayerSide()) && !(cs instanceof FakeSlot) && !(cs instanceof CraftingMatrixSlot)) {
if (cs.isItemValid(tis)) {
if (cs.canInsert(tis)) {
selectedSlots.add(cs);
}
}
@@ -376,7 +381,7 @@ public abstract class AEBaseContainer extends Container {
if (selectedSlots.isEmpty() && clickSlot.isPlayerSide()) {
if (!tis.isEmpty()) {
// target slots in the container...
for (final Object inventorySlot : this.inventorySlots) {
for (final Object inventorySlot : this.slots) {
final AppEngSlot cs = (AppEngSlot) inventorySlot;
final ItemStack destination = cs.getStack();
@@ -384,7 +389,7 @@ public abstract class AEBaseContainer extends Container {
if (Platform.itemComparisons().isSameItem(destination, tis)) {
break;
} else if (destination.isEmpty()) {
cs.putStack(tis.copy());
cs.setStack(tis.copy());
this.updateSlot(cs);
break;
}
@@ -400,14 +405,14 @@ public abstract class AEBaseContainer extends Container {
continue;
}
if (d.isItemValid(tis)) {
if (d.getHasStack()) {
if (d.canInsert(tis)) {
if (d.hasStack()) {
final ItemStack t = d.getStack().copy();
if (Platform.itemComparisons().isSameItem(t, tis)) {
int maxSize = t.getMaxCount();
if (maxSize > d.getSlotStackLimit()) {
maxSize = d.getSlotStackLimit();
if (maxSize > d.getMaxStackAmount()) {
maxSize = d.getMaxStackAmount();
}
int placeable = maxSize - t.getCount();
@@ -419,11 +424,11 @@ public abstract class AEBaseContainer extends Container {
t.setCount(t.getCount() + placeable);
tis.setCount(tis.getCount() - placeable);
d.putStack(t);
d.setStack(t);
if (tis.getCount() <= 0) {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
clickSlot.setStack(ItemStack.EMPTY);
d.markDirty();
this.updateSlot(clickSlot);
this.updateSlot(d);
@@ -444,14 +449,14 @@ public abstract class AEBaseContainer extends Container {
continue;
}
if (d.isItemValid(tis)) {
if (d.getHasStack()) {
if (d.canInsert(tis)) {
if (d.hasStack()) {
final ItemStack t = d.getStack().copy();
if (Platform.itemComparisons().isSameItem(t, tis)) {
int maxSize = t.getMaxCount();
if (maxSize > d.getSlotStackLimit()) {
maxSize = d.getSlotStackLimit();
if (maxSize > d.getMaxStackAmount()) {
maxSize = d.getMaxStackAmount();
}
int placeable = maxSize - t.getCount();
@@ -463,11 +468,11 @@ public abstract class AEBaseContainer extends Container {
t.setCount(t.getCount() + placeable);
tis.setCount(tis.getCount() - placeable);
d.putStack(t);
d.setStack(t);
if (tis.getCount() <= 0) {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
clickSlot.setStack(ItemStack.EMPTY);
d.markDirty();
this.updateSlot(clickSlot);
this.updateSlot(d);
@@ -479,8 +484,8 @@ public abstract class AEBaseContainer extends Container {
}
} else {
int maxSize = tis.getMaxCount();
if (maxSize > d.getSlotStackLimit()) {
maxSize = d.getSlotStackLimit();
if (maxSize > d.getMaxStackAmount()) {
maxSize = d.getMaxStackAmount();
}
final ItemStack tmp = tis.copy();
@@ -489,11 +494,11 @@ public abstract class AEBaseContainer extends Container {
}
tis.setCount(tis.getCount() - tmp.getCount());
d.putStack(tmp);
d.setStack(tmp);
if (tis.getCount() <= 0) {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
clickSlot.setStack(ItemStack.EMPTY);
d.markDirty();
this.updateSlot(clickSlot);
this.updateSlot(d);
@@ -506,7 +511,7 @@ public abstract class AEBaseContainer extends Container {
}
}
clickSlot.putStack(!tis.isEmpty() ? tis : ItemStack.EMPTY);
clickSlot.setStack(!tis.isEmpty() ? tis : ItemStack.EMPTY);
}
this.updateSlot(clickSlot);
@@ -514,17 +519,17 @@ public abstract class AEBaseContainer extends Container {
}
@Override
public final void updateProgressBar(final int idx, final int value) {
public final void setProperty(final int idx, final int value) {
if (this.syncData.containsKey(idx)) {
this.syncData.get(idx).update((long) value);
}
}
@Override
public boolean canInteractWith(final PlayerEntity PlayerEntity) {
public boolean canUse(PlayerEntity player) {
if (this.isValidContainer()) {
if (this.tileEntity instanceof Inventory) {
return ((Inventory) this.tileEntity).isUsableByPlayer(PlayerEntity);
return ((Inventory) this.tileEntity).canPlayerUse(player);
}
return true;
}
@@ -532,12 +537,12 @@ public abstract class AEBaseContainer extends Container {
}
@Override
public boolean canDragIntoSlot(final Slot s) {
return ((AppEngSlot) s).isDraggable();
public boolean canInsertIntoSlot(Slot slot) {
return ((AppEngSlot) slot).isDraggable();
}
public void doAction(final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id) {
if (slot >= 0 && slot < this.inventorySlots.size()) {
if (slot >= 0 && slot < this.slots.size()) {
final Slot s = this.getSlot(slot);
if (s instanceof CraftingTermSlot) {
@@ -552,15 +557,15 @@ public abstract class AEBaseContainer extends Container {
}
if (s instanceof FakeSlot) {
final ItemStack hand = player.inventory.getItemStack();
final ItemStack hand = player.inventory.getCursorStack();
switch (action) {
case PICKUP_OR_SET_DOWN:
if (hand.isEmpty()) {
s.putStack(ItemStack.EMPTY);
s.setStack(ItemStack.EMPTY);
} else {
s.putStack(hand.copy());
s.setStack(hand.copy());
}
break;
@@ -569,7 +574,7 @@ public abstract class AEBaseContainer extends Container {
if (!hand.isEmpty()) {
final ItemStack is = hand.copy();
is.setCount(1);
s.putStack(is);
s.setStack(is);
}
break;
@@ -586,11 +591,11 @@ public abstract class AEBaseContainer extends Container {
is.setCount(1);
}
s.putStack(is);
s.setStack(is);
} else if (!hand.isEmpty()) {
is = hand.copy();
is.setCount(1);
s.putStack(is);
s.setStack(is);
}
break;
@@ -603,16 +608,17 @@ public abstract class AEBaseContainer extends Container {
}
if (action == InventoryAction.MOVE_REGION) {
final List<Slot> from = new ArrayList<>();
final List<Integer> from = new ArrayList<>();
for (final Object j : this.inventorySlots) {
if (j instanceof Slot && j.getClass() == s.getClass() && !(j instanceof CraftingTermSlot)) {
from.add((Slot) j);
for (int i = 0; i < this.slots.size(); i++) {
Slot j = this.slots.get(i);
if (j.getClass() == s.getClass() && !(j instanceof CraftingTermSlot)) {
from.add(i);
}
}
for (final Slot fr : from) {
this.transferStackInSlot(player, fr.slotNumber);
for (final int fromIndex : from) {
this.transferSlot(player, fromIndex);
}
}
@@ -655,7 +661,7 @@ public abstract class AEBaseContainer extends Container {
}
final int releaseQty = 1;
final ItemStack isg = player.inventory.getItemStack();
final ItemStack isg = player.inventory.getCursorStack();
if (!isg.isEmpty() && releaseQty > 0) {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
@@ -688,7 +694,7 @@ public abstract class AEBaseContainer extends Container {
if (slotItem != null) {
int liftQty = 1;
final ItemStack item = player.inventory.getItemStack();
final ItemStack item = player.inventory.getCursorStack();
if (!item.isEmpty()) {
if (item.getCount() >= item.getMaxCount()) {
@@ -723,28 +729,28 @@ public abstract class AEBaseContainer extends Container {
return;
}
if (player.inventory.getItemStack().isEmpty()) {
if (player.inventory.getCursorStack().isEmpty()) {
if (slotItem != null) {
IAEItemStack ais = slotItem.copy();
ais.setStackSize(ais.getDefinition().getMaxCount());
ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource());
if (ais != null) {
player.inventory.setItemStack(ais.createItemStack());
player.inventory.setCursorStack(ais.createItemStack());
} else {
player.inventory.setItemStack(ItemStack.EMPTY);
player.inventory.setCursorStack(ItemStack.EMPTY);
}
this.updateHeld(player);
}
} else {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(player.inventory.getItemStack());
.createStack(player.inventory.getCursorStack());
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource());
if (ais != null) {
player.inventory.setItemStack(ais.createItemStack());
player.inventory.setCursorStack(ais.createItemStack());
} else {
player.inventory.setItemStack(ItemStack.EMPTY);
player.inventory.setCursorStack(ItemStack.EMPTY);
}
this.updateHeld(player);
}
@@ -755,7 +761,7 @@ public abstract class AEBaseContainer extends Container {
return;
}
if (player.inventory.getItemStack().isEmpty()) {
if (player.inventory.getCursorStack().isEmpty()) {
if (slotItem != null) {
IAEItemStack ais = slotItem.copy();
final long maxSize = ais.getDefinition().getMaxCount();
@@ -770,23 +776,23 @@ public abstract class AEBaseContainer extends Container {
}
if (ais != null) {
player.inventory.setItemStack(ais.createItemStack());
player.inventory.setCursorStack(ais.createItemStack());
} else {
player.inventory.setItemStack(ItemStack.EMPTY);
player.inventory.setCursorStack(ItemStack.EMPTY);
}
this.updateHeld(player);
}
} else {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(player.inventory.getItemStack());
.createStack(player.inventory.getCursorStack());
ais.setStackSize(1);
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource());
if (ais == null) {
final ItemStack is = player.inventory.getItemStack();
final ItemStack is = player.inventory.getCursorStack();
is.setCount(is.getCount() - 1);
if (is.getCount() <= 0) {
player.inventory.setItemStack(ItemStack.EMPTY);
player.inventory.setCursorStack(ItemStack.EMPTY);
}
this.updateHeld(player);
}
@@ -794,10 +800,10 @@ public abstract class AEBaseContainer extends Container {
break;
case CREATIVE_DUPLICATE:
if (player.abilities.isCreativeMode && slotItem != null) {
if (player.isCreative() && slotItem != null) {
final ItemStack is = slotItem.createItemStack();
is.setCount(is.getMaxCount());
player.inventory.setItemStack(is);
player.inventory.setCursorStack(is);
this.updateHeld(player);
}
break;
@@ -842,7 +848,7 @@ public abstract class AEBaseContainer extends Container {
protected void updateHeld(final ServerPlayerEntity p) {
if (Platform.isServer()) {
NetworkHandler.instance().sendTo(new InventoryActionPacket(InventoryAction.UPDATE_HAND, 0,
AEItemStack.fromItemStack(p.inventory.getItemStack())), p);
AEItemStack.fromItemStack(p.inventory.getCursorStack())), p);
}
}
@@ -865,7 +871,7 @@ public abstract class AEBaseContainer extends Container {
private void updateSlot(final Slot clickSlot) {
// ???
this.detectAndSendChanges();
this.sendContentUpdates();
}
private void sendCustomName() {
@@ -924,21 +930,21 @@ public abstract class AEBaseContainer extends Container {
// can take?
if (!isA.isEmpty() && !a.canTakeStack(this.getPlayerInventory().player)) {
if (!isA.isEmpty() && !a.canTakeItems(this.getPlayerInventory().player)) {
return;
}
if (!isB.isEmpty() && !b.canTakeStack(this.getPlayerInventory().player)) {
if (!isB.isEmpty() && !b.canTakeItems(this.getPlayerInventory().player)) {
return;
}
// swap valid?
if (!isB.isEmpty() && !a.isItemValid(isB)) {
if (!isB.isEmpty() && !a.canInsert(isB)) {
return;
}
if (!isA.isEmpty() && !b.isItemValid(isA)) {
if (!isA.isEmpty() && !b.canInsert(isA)) {
return;
}
@@ -946,32 +952,32 @@ public abstract class AEBaseContainer extends Container {
ItemStack testB = isA.isEmpty() ? ItemStack.EMPTY : isA.copy();
// can put some back?
if (!testA.isEmpty() && testA.getCount() > a.getSlotStackLimit()) {
if (!testA.isEmpty() && testA.getCount() > a.getMaxStackAmount()) {
if (!testB.isEmpty()) {
return;
}
final int totalA = testA.getCount();
testA.setCount(a.getSlotStackLimit());
testA.setCount(a.getMaxStackAmount());
testB = testA.copy();
testB.setCount(totalA - testA.getCount());
}
if (!testB.isEmpty() && testB.getCount() > b.getSlotStackLimit()) {
if (!testB.isEmpty() && testB.getCount() > b.getMaxStackAmount()) {
if (!testA.isEmpty()) {
return;
}
final int totalB = testB.getCount();
testB.setCount(b.getSlotStackLimit());
testB.setCount(b.getMaxStackAmount());
testA = testB.copy();
testA.setCount(totalB - testA.getCount());
}
a.putStack(testA);
b.putStack(testB);
a.setStack(testA);
b.setStack(testB);
}
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
@@ -18,7 +18,10 @@
package appeng.container;
import appeng.api.parts.IPartHost;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.parts.AEBasePart;
import com.google.common.base.Preconditions;
import io.netty.handler.codec.DecoderException;
import net.minecraft.block.entity.BlockEntity;
@@ -123,12 +126,11 @@ public final class ContainerLocator {
throw new IllegalArgumentException("Could not find item held in hand " + hand + " in player inventory");
}
// FIXME FABRIC public static ContainerLocator forPart(AEBasePart part) {
// FIXME FABRIC IPartHost host = part.getHost();
// FIXME FABRIC DimensionalCoord pos = host.getLocation();
// FIXME FABRIC return new ContainerLocator(Type.PART, -1, pos.getWorld().getDimension().getType().getId(), pos.getBlockPos(),
// FIXME FABRIC part.getSide());
// FIXME FABRIC }
public static ContainerLocator forPart(AEBasePart part) {
IPartHost host = part.getHost();
DimensionalCoord pos = host.getLocation();
return new ContainerLocator(Type.PART, -1, pos.getWorld().getWorld(), pos.getBlockPos(), part.getSide());
}
public boolean hasItemIndex() {
return type == Type.PLAYER_INVENTORY || type == Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT;
@@ -19,19 +19,19 @@
package appeng.container;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.Container;
import net.minecraft.screen.ScreenHandler;
/*
* Totally useless container that does nothing.
*/
public class ContainerNull extends Container {
public class ContainerNull extends ScreenHandler {
public ContainerNull() {
super(null, 0);
}
@Override
public boolean canInteractWith(final PlayerEntity PlayerEntity) {
public boolean canUse(PlayerEntity player) {
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More