reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
+241 -298
View File
@@ -19,15 +19,31 @@
package appeng.client;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import appeng.api.parts.CableRenderMode;
import appeng.api.util.AEColor;
import appeng.block.AEBaseBlock;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.effects.*;
import appeng.client.render.model.UVLModelLoader;
import appeng.client.render.tesr.InscriberTESR;
import appeng.client.render.textures.ParticleTextures;
import appeng.container.interfaces.IJEIGhostIngredients;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
import appeng.entity.RenderTinyTNTPrimed;
import appeng.helpers.HighlighterHandler;
import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor;
import appeng.server.ServerHelper;
import appeng.util.Platform;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
@@ -47,343 +63,270 @@ import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import appeng.api.parts.CableRenderMode;
import appeng.api.util.AEColor;
import appeng.block.AEBaseBlock;
import appeng.client.render.effects.AssemblerFX;
import appeng.client.render.effects.CraftingFx;
import appeng.client.render.effects.EnergyFx;
import appeng.client.render.effects.LightningArcFX;
import appeng.client.render.effects.LightningFX;
import appeng.client.render.effects.VibrantFX;
import appeng.client.render.model.UVLModelLoader;
import appeng.client.render.tesr.InscriberTESR;
import appeng.client.render.textures.ParticleTextures;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
import appeng.entity.RenderTinyTNTPrimed;
import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor;
import appeng.server.ServerHelper;
import appeng.util.Platform;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
public class ClientHelper extends ServerHelper
{
private final static String KEY_CATEGORY = "key.appliedenergistics2.category";
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>( ActionKey.class );
public class ClientHelper extends ServerHelper {
private final static String KEY_CATEGORY = "key.appliedenergistics2.category";
@Override
public void preinit()
{
MinecraftForge.EVENT_BUS.register( this );
// Do not register the Fullbright hacks if Optifine is present or if the Forge lighting is disabled
if( !FMLClientHandler.instance().hasOptifine() && ForgeModContainer.forgeLightPipelineEnabled )
{
ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
}
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>(ActionKey.class);
RenderingRegistry.registerEntityRenderingHandler( EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed( manager ) );
RenderingRegistry.registerEntityRenderingHandler( EntityFloatingItem.class, manager -> new RenderFloatingItem( manager ) );
}
@Override
public void preinit() {
MinecraftForge.EVENT_BUS.register(this);
// Do not register the Fullbright hacks if Optifine is present or if the Forge lighting is disabled
if (!FMLClientHandler.instance().hasOptifine() && ForgeModContainer.forgeLightPipelineEnabled) {
ModelLoaderRegistry.registerLoader(UVLModelLoader.INSTANCE);
}
@Override
public void init()
{
for( ActionKey key : ActionKey.values() )
{
final KeyBinding binding = new KeyBinding( key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY );
ClientRegistry.registerKeyBinding( binding );
this.bindings.put( key, binding );
}
}
RenderingRegistry.registerEntityRenderingHandler(EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed(manager));
RenderingRegistry.registerEntityRenderingHandler(EntityFloatingItem.class, manager -> new RenderFloatingItem(manager));
}
@SubscribeEvent
public void renderWorldLastEvent( RenderWorldLastEvent event) {
HighlighterHandler.tick(event);
}
@Override
public void init() {
for (ActionKey key : ActionKey.values()) {
final KeyBinding binding = new KeyBinding(key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY);
ClientRegistry.registerKeyBinding(binding);
this.bindings.put(key, binding);
}
}
@Override
public World getWorld()
{
if( Platform.isClient() )
{
return Minecraft.getMinecraft().world;
}
else
{
return super.getWorld();
}
}
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
HighlighterHandler.tick(event);
}
@Override
public void bindTileEntitySpecialRenderer( final Class<? extends TileEntity> tile, final AEBaseBlock blk )
{
@Override
public World getWorld() {
if (Platform.isClient()) {
return Minecraft.getMinecraft().world;
} else {
return super.getWorld();
}
}
}
@Override
public void bindTileEntitySpecialRenderer(final Class<? extends TileEntity> tile, final AEBaseBlock blk) {
@Override
public List<EntityPlayer> getPlayers()
{
if( Platform.isClient() )
{
final List<EntityPlayer> o = new ArrayList<>();
o.add( Minecraft.getMinecraft().player );
return o;
}
else
{
return super.getPlayers();
}
}
}
@Override
public void spawnEffect( final EffectType effect, final World world, final double posX, final double posY, final double posZ, final Object o )
{
if( AEConfig.instance().isEnableEffects() )
{
switch( effect )
{
case Assembler:
this.spawnAssembler( world, posX, posY, posZ, o );
return;
case Vibrant:
this.spawnVibrant( world, posX, posY, posZ );
return;
case Crafting:
this.spawnCrafting( world, posX, posY, posZ );
return;
case Energy:
this.spawnEnergy( world, posX, posY, posZ );
return;
case Lightning:
this.spawnLightning( world, posX, posY, posZ );
return;
case LightningArc:
this.spawnLightningArc( world, posX, posY, posZ, (Vec3d) o );
return;
default:
}
}
}
@Override
public List<EntityPlayer> getPlayers() {
if (Platform.isClient()) {
final List<EntityPlayer> o = new ArrayList<>();
o.add(Minecraft.getMinecraft().player);
return o;
} else {
return super.getPlayers();
}
}
@Override
public boolean shouldAddParticles( final Random r )
{
final int setting = Minecraft.getMinecraft().gameSettings.particleSetting;
if( setting == 2 )
{
return false;
}
if( setting == 0 )
{
return true;
}
return r.nextInt( 2 * ( setting + 1 ) ) == 0;
}
@Override
public void spawnEffect(final EffectType effect, final World world, final double posX, final double posY, final double posZ, final Object o) {
if (AEConfig.instance().isEnableEffects()) {
switch (effect) {
case Assembler:
this.spawnAssembler(world, posX, posY, posZ, o);
return;
case Vibrant:
this.spawnVibrant(world, posX, posY, posZ);
return;
case Crafting:
this.spawnCrafting(world, posX, posY, posZ);
return;
case Energy:
this.spawnEnergy(world, posX, posY, posZ);
return;
case Lightning:
this.spawnLightning(world, posX, posY, posZ);
return;
case LightningArc:
this.spawnLightningArc(world, posX, posY, posZ, (Vec3d) o);
return;
default:
}
}
}
@Override
public RayTraceResult getRTR()
{
return Minecraft.getMinecraft().objectMouseOver;
}
@Override
public boolean shouldAddParticles(final Random r) {
final int setting = Minecraft.getMinecraft().gameSettings.particleSetting;
if (setting == 2) {
return false;
}
if (setting == 0) {
return true;
}
return r.nextInt(2 * (setting + 1)) == 0;
}
@Override
public void postInit()
{
}
@Override
public RayTraceResult getRTR() {
return Minecraft.getMinecraft().objectMouseOver;
}
@Override
public CableRenderMode getRenderMode()
{
if( Platform.isServer() )
{
return super.getRenderMode();
}
@Override
public void postInit() {
}
final Minecraft mc = Minecraft.getMinecraft();
final EntityPlayer player = mc.player;
@Override
public CableRenderMode getRenderMode() {
if (Platform.isServer()) {
return super.getRenderMode();
}
return this.renderModeForPlayer( player );
}
final Minecraft mc = Minecraft.getMinecraft();
final EntityPlayer player = mc.player;
@Override
public void triggerUpdates()
{
final Minecraft mc = Minecraft.getMinecraft();
if( mc == null || mc.player == null || mc.world == null )
{
return;
}
return this.renderModeForPlayer(player);
}
final EntityPlayer player = mc.player;
@Override
public void triggerUpdates() {
final Minecraft mc = Minecraft.getMinecraft();
if (mc == null || mc.player == null || mc.world == null) {
return;
}
final int x = (int) player.posX;
final int y = (int) player.posY;
final int z = (int) player.posZ;
final EntityPlayer player = mc.player;
final int range = 16 * 16;
final int x = (int) player.posX;
final int y = (int) player.posY;
final int z = (int) player.posZ;
mc.world.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
}
final int range = 16 * 16;
@SubscribeEvent
public void postPlayerRender( final RenderLivingEvent.Pre p )
{
final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.getEntity().getEntityId() );
if( player != null )
{
final AEColor col = player.myColor;
mc.world.markBlockRangeForRenderUpdate(x - range, y - range, z - range, x + range, y + range, z + range);
}
final float r = 0xff & ( col.mediumVariant >> 16 );
final float g = 0xff & ( col.mediumVariant >> 8 );
final float b = 0xff & ( col.mediumVariant );
GlStateManager.color( r / 255.0f, g / 255.0f, b / 255.0f );
}
}
@SubscribeEvent
public void postPlayerRender(final RenderLivingEvent.Pre p) {
final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get(p.getEntity().getEntityId());
if (player != null) {
final AEColor col = player.myColor;
private void spawnAssembler( final World world, final double posX, final double posY, final double posZ, final Object o )
{
final PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
final float r = 0xff & (col.mediumVariant >> 16);
final float g = 0xff & (col.mediumVariant >> 8);
final float b = 0xff & (col.mediumVariant);
GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f);
}
}
final AssemblerFX fx = new AssemblerFX( world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
private void spawnAssembler(final World world, final double posX, final double posY, final double posZ, final Object o) {
final PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
private void spawnVibrant( final World w, final double x, final double y, final double z )
{
if( AppEng.proxy.shouldAddParticles( Platform.getRandom() ) )
{
final double d0 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
final double d1 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
final double d2 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
final AssemblerFX fx = new AssemblerFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
final VibrantFX fx = new VibrantFX( w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
private void spawnVibrant(final World w, final double x, final double y, final double z) {
if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) {
final double d0 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
final double d1 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
final double d2 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
private void spawnCrafting( final World w, final double posX, final double posY, final double posZ )
{
final float x = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
final float y = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
final float z = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
final VibrantFX fx = new VibrantFX(w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
}
final CraftingFx fx = new CraftingFx( w, posX + x, posY + y, posZ + z, Items.DIAMOND );
private void spawnCrafting(final World w, final double posX, final double posY, final double posZ) {
final float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
final float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
final float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
fx.setMotionX( -x * 0.2f );
fx.setMotionY( -y * 0.2f );
fx.setMotionZ( -z * 0.2f );
final CraftingFx fx = new CraftingFx(w, posX + x, posY + y, posZ + z, Items.DIAMOND);
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
fx.setMotionX(-x * 0.2f);
fx.setMotionY(-y * 0.2f);
fx.setMotionZ(-z * 0.2f);
private void spawnEnergy( final World w, final double posX, final double posY, final double posZ )
{
final float x = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
final float y = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
final float z = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
final EnergyFx fx = new EnergyFx( w, posX + x, posY + y, posZ + z, Items.DIAMOND );
private void spawnEnergy(final World w, final double posX, final double posY, final double posZ) {
final float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
final float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
final float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
fx.setMotionX( -x * 0.1f );
fx.setMotionY( -y * 0.1f );
fx.setMotionZ( -z * 0.1f );
final EnergyFx fx = new EnergyFx(w, posX + x, posY + y, posZ + z, Items.DIAMOND);
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
fx.setMotionX(-x * 0.1f);
fx.setMotionY(-y * 0.1f);
fx.setMotionZ(-z * 0.1f);
private void spawnLightning( final World world, final double posX, final double posY, final double posZ )
{
final LightningFX fx = new LightningFX( world, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
private void spawnLightningArc( final World world, final double posX, final double posY, final double posZ, final Vec3d second )
{
final LightningFX fx = new LightningArcFX( world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
private void spawnLightning(final World world, final double posX, final double posY, final double posZ) {
final LightningFX fx = new LightningFX(world, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
@SubscribeEvent
public void MouseClickEvent( final GuiScreenEvent.MouseInputEvent.Pre me )
{
final Minecraft mc = Minecraft.getMinecraft();
if( mc.currentScreen instanceof IJEIGhostIngredients )
{
AEBaseGui gui = ( (AEBaseGui) mc.currentScreen );
Object ingredient = gui.getBookmarkedIngredient();
if( ingredient != null )
{
if( GuiScreen.isShiftKeyDown() )
{
me.setCanceled( true );
}
else if( Mouse.isButtonDown( 0 ) )
{
me.setCanceled( true );
}
}
}
}
private void spawnLightningArc(final World world, final double posX, final double posY, final double posZ, final Vec3d second) {
final LightningFX fx = new LightningArcFX(world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, 0.0f);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
@SubscribeEvent
public void wheelEvent( final MouseEvent me )
{
if( me.getDwheel() == 0 )
{
return;
}
@SubscribeEvent
public void MouseClickEvent(final GuiScreenEvent.MouseInputEvent.Pre me) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.currentScreen instanceof IJEIGhostIngredients) {
AEBaseGui gui = ((AEBaseGui) mc.currentScreen);
Object ingredient = gui.getBookmarkedIngredient();
if (ingredient != null) {
if (GuiScreen.isShiftKeyDown()) {
me.setCanceled(true);
} else if (Mouse.isButtonDown(0)) {
me.setCanceled(true);
}
}
}
}
final Minecraft mc = Minecraft.getMinecraft();
final EntityPlayer player = mc.player;
if( player.isSneaking() )
{
final boolean mainHand = player.getHeldItem( EnumHand.MAIN_HAND ).getItem() instanceof IMouseWheelItem;
final boolean offHand = player.getHeldItem( EnumHand.OFF_HAND ).getItem() instanceof IMouseWheelItem;
@SubscribeEvent
public void wheelEvent(final MouseEvent me) {
if (me.getDwheel() == 0) {
return;
}
if( mainHand || offHand )
{
try
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getDwheel() > 0 ? "WheelUp" : "WheelDown" ) );
me.setCanceled( true );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
}
}
final Minecraft mc = Minecraft.getMinecraft();
final EntityPlayer player = mc.player;
if (player.isSneaking()) {
final boolean mainHand = player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof IMouseWheelItem;
final boolean offHand = player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof IMouseWheelItem;
@SubscribeEvent
public void onTextureStitch( final TextureStitchEvent.Pre event )
{
ParticleTextures.registerSprite( event );
InscriberTESR.registerTexture( event );
}
if (mainHand || offHand) {
try {
NetworkHandler.instance().sendToServer(new PacketValueConfig("Item", me.getDwheel() > 0 ? "WheelUp" : "WheelDown"));
me.setCanceled(true);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
}
@Override
public boolean isKeyPressed( ActionKey key )
{
return this.bindings.get( key ).isPressed();
}
@SubscribeEvent
public void onTextureStitch(final TextureStitchEvent.Pre event) {
ParticleTextures.registerSprite(event);
InscriberTESR.registerTexture(event);
}
@Override
public boolean isActionKey( ActionKey key, int pressedKeyCode )
{
return this.bindings.get( key ).isActiveAndMatches( pressedKeyCode );
}
@Override
public boolean isKeyPressed(ActionKey key) {
return this.bindings.get(key).isPressed();
}
@Override
public boolean isActionKey(ActionKey key, int pressedKeyCode) {
return this.bindings.get(key).isActiveAndMatches(pressedKeyCode);
}
}