Connected Glass

This commit is contained in:
Sebastian Hartte
2020-06-01 13:13:18 +02:00
parent c1f260d95f
commit adfc2577ed
34 changed files with 344 additions and 346 deletions
+22
View File
@@ -21,6 +21,8 @@ package appeng.core;
import java.io.File;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IClientSetupComponent;
import appeng.client.ClientHelper;
import appeng.core.features.AEFeature;
import appeng.server.ServerHelper;
@@ -28,9 +30,12 @@ import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.particles.ParticleType;
import net.minecraft.stats.StatType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.CrashReportExtender;
import net.minecraftforge.fml.DistExecutor;
@@ -41,7 +46,11 @@ import net.minecraftforge.fml.config.ModConfig;
import appeng.core.crash.ModCrashEnhancement;
import appeng.services.export.ExportConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.registries.IForgeRegistry;
@Mod(AppEng.MOD_ID)
public final class AppEng
@@ -95,9 +104,22 @@ public final class AppEng
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
modEventBus.addListener(registration::registerParticleFactories);
modEventBus.addListener(this::commonSetup);
// Register client-only events
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup));
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::modelRegistryEvent));
}
private void commonSetup(FMLCommonSetupEvent event) {
}
@OnlyIn(Dist.CLIENT)
private void clientSetup(FMLClientSetupEvent event) {
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents( IClientSetupComponent.class ).forEachRemaining(IClientSetupComponent::setup);
}
// @Nonnull
// public static AppEng instance()
// {
+8 -1
View File
@@ -26,6 +26,7 @@ import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IModelRegistrationComponent;
import appeng.client.render.effects.ChargedOreFX;
import appeng.client.render.model.GlassModelLoader;
import appeng.core.stats.AeStats;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
@@ -33,7 +34,11 @@ import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.particles.ParticleType;
import net.minecraft.stats.IStatFormatter;
import net.minecraft.stats.StatType;
import net.minecraft.stats.Stats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelRegistryEvent;
@@ -49,6 +54,8 @@ final class Registration
public Registration() {
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "glass"), GlassModelLoader.INSTANCE);
AeStats.register();
}
// DimensionType storageDimensionType;
@@ -260,7 +267,7 @@ final class Registration
registry.register(ChargedOreFX.TYPE);
}
public void registerParticleFactories(ParticleFactoryRegisterEvent evt) {
public void registerParticleFactories(ParticleFactoryRegisterEvent event) {
Minecraft.getInstance().particles.registerFactory(ChargedOreFX.TYPE, ChargedOreFX.Factory::new);
}
@@ -26,13 +26,16 @@ import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.client.render.model.GlassModel;
import appeng.core.features.AEFeature;
import appeng.core.features.registries.PartModels;
import appeng.decorative.AEDecorativeBlock;
import appeng.decorative.solid.*;
import appeng.decorative.solid.BlockChargedQuartzOre;
import appeng.decorative.solid.BlockQuartzGlass;
import appeng.decorative.solid.BlockQuartzOre;
import appeng.decorative.solid.BlockQuartzPillar;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -140,16 +143,13 @@ public final class ApiBlocks implements IBlocks
this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS )
.block( "quartz_glass", BlockQuartzGlass::new )
// .useCustomItemModel()
// .rendering( new BlockRenderingCustomizer()
// {
// @Override
// @OnlyIn( Dist.CLIENT)
// public void customize(IBlockRendering rendering, IItemRendering itemRendering )
// {
// rendering.builtInModel( "models/block/builtin/quartz_glass", new GlassModel() );
// }
// } )
.rendering(new BlockRenderingCustomizer() {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
}
})
.build();
// this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", BlockQuartzLamp::new )
// .addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS )
@@ -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.core.stats;
import appeng.core.AppEng;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.stats.IStatFormatter;
import net.minecraft.stats.Stats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
public enum AeStats
{
// done
ItemsInserted("items_inserted"),
// done
ItemsExtracted("items_extracted"),
// done
TurnedCranks("turned_cranks");
private final ResourceLocation registryName;
AeStats(String id) {
this.registryName = new ResourceLocation(AppEng.MOD_ID, id);
}
public void addToPlayer(final PlayerEntity player, final int howMany )
{
player.addStat( this.registryName, howMany );
}
public ResourceLocation getRegistryName() {
return registryName;
}
public static void register() {
for (AeStats stat : AeStats.values()) {
// Compare with net.minecraft.stats.Stats#registerCustom
ResourceLocation registryName = stat.getRegistryName();
Registry.register(Registry.CUSTOM_STAT, registryName.getPath(), registryName);
Stats.CUSTOM.get(registryName, IStatFormatter.DEFAULT);
}
}
}
@@ -1,61 +0,0 @@
/*
* 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.core.stats;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.stats.StatBasic;
import net.minecraft.util.text.TextComponentTranslation;
public enum Stats
{
// done
ItemsInserted,
// done
ItemsExtracted,
// done
TurnedCranks;
private StatBasic stat;
Stats()
{
}
public void addToPlayer( final PlayerEntity player, final int howMany )
{
player.addStat( this.stat, howMany );
}
public static void register()
{
for( final Stats s : Stats.values() )
{
if( s.stat == null )
{
s.stat = new StatBasic( "stat.ae2." + s.name(), new TextComponentTranslation( "stat.ae2." + s.name() ) );
s.stat.registerStat();
}
}
}
}
@@ -34,7 +34,6 @@ import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
import appeng.core.sync.network.INetworkInfo;
import appeng.core.sync.network.NetworkHandler;
public abstract class AppEngPacket
@@ -48,7 +47,8 @@ public abstract class AppEngPacket
public final int getPacketID()
{
return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
throw new IllegalStateException();
// FIXME return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
}
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
@@ -74,7 +74,8 @@ public abstract class AppEngPacket
AELog.info( this.getClass().getName() + " : " + p.readableBytes() );
}
return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
// FIXME return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
return null;
}
// TODO: Figure out why Forge/Minecraft on the server sets the stream data buffer to PooledUnsafeDirectByteBuf
@@ -22,7 +22,6 @@ package appeng.core.sync.network;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.INetHandler;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.PacketDispatcher;
public interface IPacketHandler
@@ -29,18 +29,14 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IItems;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.block.networking.BlockCableBus;
import appeng.core.Api;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.ToolNetworkTool;
import appeng.items.tools.powered.ToolColorApplicator;
public class PacketClick extends AppEngPacket
@@ -120,34 +116,34 @@ public class PacketClick extends AppEngPacket
if( this.leftClick )
{
final Block block = player.world.getBlockState( pos ).getBlock();
if( block instanceof BlockCableBus )
{
( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) );
}
// FIXME if( block instanceof BlockCableBus )
// FIXME {
// FIXME ( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) );
// FIXME }
}
else
{
if( !is.isEmpty() )
{
if( is.getItem() instanceof ToolNetworkTool )
{
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
tnt.serverSideToolLogic( is, player, this.hand, player.world, pos, this.side, this.hitX, this.hitY,
this.hitZ );
}
// FIXME if( is.getItem() instanceof ToolNetworkTool )
// FIXME {
// FIXME final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
// FIXME tnt.serverSideToolLogic( is, player, this.hand, player.world, pos, this.side, this.hitX, this.hitY,
// FIXME this.hitZ );
// FIXME }
else if( maybeMemoryCard.isSameAs( is ) )
/* FIXME else */ if( maybeMemoryCard.isSameAs( is ) )
{
final IMemoryCard mem = (IMemoryCard) is.getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
is.setTag( null );
}
else if( maybeColorApplicator.isSameAs( is ) )
{
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
mem.cycleColors( is, mem.getColor( is ), 1 );
}
// FIXME else if( maybeColorApplicator.isSameAs( is ) )
// FIXME {
// FIXME final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
// FIXME mem.cycleColors( is, mem.getColor( is ), 1 );
// FIXME }
}
}
}
@@ -30,7 +30,6 @@ import appeng.api.util.DimensionalCoord;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.worlddata.WorldData;
import appeng.services.compass.ICompassCallback;
@@ -79,6 +78,6 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
this.talkBackTo = player;
final DimensionalCoord loc = new DimensionalCoord( player.world, this.cx << 4, this.cdy << 5, this.cz << 4 );
WorldData.instance().compassData().service().getCompassDirection( loc, 174, this );
// FIXME WorldData.instance().compassData().service().getCompassDirection( loc, 174, this );
}
}
@@ -39,7 +39,6 @@ import net.minecraft.network.PacketBuffer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.client.gui.implementations.GuiInterfaceTerminal;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
@@ -113,9 +112,9 @@ public class PacketCompressedNBT extends AppEngPacket
{
final Screen gs = Minecraft.getInstance().currentScreen;
if( gs instanceof GuiInterfaceTerminal )
{
( (GuiInterfaceTerminal) gs ).postUpdate( this.in );
}
// FIXME if( gs instanceof GuiInterfaceTerminal )
// FIXME {
// FIXME ( (GuiInterfaceTerminal) gs ).postUpdate( this.in );
// FIXME }
}
}
@@ -29,7 +29,6 @@ import net.minecraft.network.PacketBuffer;
import appeng.api.config.Settings;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.Platform;
@@ -65,15 +64,15 @@ public final class PacketConfigButton extends AppEngPacket
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
{
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
if( sender.openContainer instanceof AEBaseContainer )
{
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
if( baseContainer.getTarget() instanceof IConfigurableObject )
{
final IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
final Enum<?> newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
cm.putSetting( this.option, newState );
}
}
// FIXME if( sender.openContainer instanceof AEBaseContainer )
// FIXME {
// FIXME final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
// FIXME if( baseContainer.getTarget() instanceof IConfigurableObject )
// FIXME {
// FIXME final IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
// FIXME final Enum<?> newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
// FIXME cm.putSetting( this.option, newState );
// FIXME }
// FIXME }
}
}
@@ -34,8 +34,6 @@ import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.security.IActionHost;
import appeng.container.ContainerOpenContext;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.core.AELog;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.GuiBridge;
@@ -71,7 +71,7 @@ public final class WorldData implements IWorldData
private final File spawnDirectory;
private final File compassDirectory;
private final Configuration sharedConfig;
// FIXME private final Configuration sharedConfig;
private WorldData( @Nonnull final File worldDirectory )
{