pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,10 +18,6 @@
package appeng.block.paint;
import appeng.block.AEBaseTileBlock;
import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
@@ -40,75 +36,69 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.block.AEBaseTileBlock;
import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
public class BlockPaint extends AEBaseTileBlock<TilePaint>
{
public BlockPaint()
{
super(defaultProps(Material.WATER, MaterialColor.AIR));
this.setFullSize( false );
this.setOpaque( false );
}
public class BlockPaint extends AEBaseTileBlock<TilePaint> {
public BlockPaint() {
super(defaultProps(Material.WATER, MaterialColor.AIR));
this.setFullSize(false);
this.setOpaque(false);
}
@Override
@OnlyIn( Dist.CLIENT )
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
{
// do nothing
}
@Override
@OnlyIn(Dist.CLIENT)
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
// do nothing
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapes.empty();
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapes.empty();
}
@Override
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
{
final TilePaint tp = this.getTileEntity( world, pos );
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final TilePaint tp = this.getTileEntity(world, pos);
if( tp != null )
{
tp.neighborChanged();
}
}
if (tp != null) {
tp.neighborChanged();
}
}
@Override
public void fillWithRain( final World w, final BlockPos pos )
{
if( Platform.isServer() )
{
w.removeBlock(pos, false);
}
}
@Override
public void fillWithRain(final World w, final BlockPos pos) {
if (Platform.isServer()) {
w.removeBlock(pos, false);
}
}
@Override
public int getLightValue( final BlockState state, final IBlockReader w, final BlockPos pos )
{
final TilePaint tp = this.getTileEntity( w, pos );
@Override
public int getLightValue(final BlockState state, final IBlockReader w, final BlockPos pos) {
final TilePaint tp = this.getTileEntity(w, pos);
if( tp != null )
{
return tp.getLightLevel();
}
if (tp != null) {
return tp.getLightLevel();
}
return 0;
}
return 0;
}
@Override
public boolean isAir( final BlockState state, final IBlockReader world, final BlockPos pos )
{
return true;
}
@Override
public boolean isAir(final BlockState state, final IBlockReader world, final BlockPos pos) {
return true;
}
@Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
return true;
}
@Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
return true;
}
@Override
public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) {
return true;
}
@Override
public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) {
return true;
}
}
@@ -1,7 +1,6 @@
package appeng.block.paint;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -10,16 +9,13 @@ import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
public class PaintRendering extends BlockRenderingCustomizer {
public class PaintRendering extends BlockRenderingCustomizer
{
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.renderType(RenderType.getCutout());
// Disable auto rotation
rendering.modelCustomizer( ( location, model ) -> model );
}
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
// Disable auto rotation
rendering.modelCustomizer((location, model) -> model);
}
}
@@ -1,7 +1,6 @@
package appeng.block.paint;
import java.util.Collection;
import java.util.List;
@@ -9,23 +8,20 @@ import com.google.common.collect.ImmutableList;
import appeng.helpers.Splotch;
/**
* Used to transfer the state about paint splotches from the game thread to the render thread.
* Used to transfer the state about paint splotches from the game thread to the
* render thread.
*/
public class PaintSplotches
{
public class PaintSplotches {
private final List<Splotch> splotches;
private final List<Splotch> splotches;
public PaintSplotches( Collection<Splotch> splotches )
{
this.splotches = ImmutableList.copyOf( splotches );
}
public PaintSplotches(Collection<Splotch> splotches) {
this.splotches = ImmutableList.copyOf(splotches);
}
List<Splotch> getSplotches()
{
return this.splotches;
}
List<Splotch> getSplotches() {
return this.splotches;
}
}
@@ -1,7 +1,6 @@
package appeng.block.paint;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -11,7 +10,6 @@ import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.tile.misc.TilePaint;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
@@ -24,172 +22,158 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.AppEng;
import appeng.helpers.Splotch;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import appeng.tile.misc.TilePaint;
/**
* Renders paint blocks, which render multiple "splotches" that have been applied to the sides of adjacent blocks using
* a
* matter cannon with paint balls.
* 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 IDynamicBakedModel {
private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/paint1" ));
private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/paint2" ));
private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/paint3" ));
private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/paint1"));
private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/paint2"));
private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/paint3"));
private final TextureAtlasSprite[] textures;
private final TextureAtlasSprite[] textures;
PaintSplotchesBakedModel(Function<Material, TextureAtlasSprite> bakedTextureGetter )
{
this.textures = new TextureAtlasSprite[] {
bakedTextureGetter.apply( TEXTURE_PAINT1 ),
bakedTextureGetter.apply( TEXTURE_PAINT2 ),
bakedTextureGetter.apply( TEXTURE_PAINT3 )
};
}
PaintSplotchesBakedModel(Function<Material, TextureAtlasSprite> bakedTextureGetter) {
this.textures = new TextureAtlasSprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1),
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) {
@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
@Nonnull IModelData extraData) {
if( side != null )
{
return Collections.emptyList();
}
if (side != null) {
return Collections.emptyList();
}
PaintSplotches splotchesState = extraData.getData(TilePaint.SPLOTCHES);
PaintSplotches splotchesState = extraData.getData(TilePaint.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;
}
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;
}
List<Splotch> splotches = splotchesState.getSplotches();
List<Splotch> splotches = splotchesState.getSplotches();
CubeBuilder builder = new CubeBuilder( );
CubeBuilder builder = new CubeBuilder();
float offsetConstant = 0.001f;
for( final Splotch s : splotches )
{
float offsetConstant = 0.001f;
for (final Splotch s : splotches) {
if( s.isLumen() )
{
builder.setColorRGB( s.getColor().whiteVariant );
builder.setRenderFullBright( true );
}
else
{
builder.setColorRGB( s.getColor().mediumVariant );
builder.setRenderFullBright( false );
}
if (s.isLumen()) {
builder.setColorRGB(s.getColor().whiteVariant);
builder.setRenderFullBright(true);
} else {
builder.setColorRGB(s.getColor().mediumVariant);
builder.setRenderFullBright(false);
}
float offset = offsetConstant;
offsetConstant += 0.001f;
float offset = offsetConstant;
offsetConstant += 0.001f;
final float buffer = 0.1f;
final float buffer = 0.1f;
float pos_x = s.x();
float pos_y = s.y();
float pos_x = s.x();
float pos_y = s.y();
pos_x = Math.max( buffer, Math.min( 1.0f - buffer, pos_x ) );
pos_y = Math.max( buffer, Math.min( 1.0f - buffer, pos_y ) );
pos_x = Math.max(buffer, Math.min(1.0f - buffer, pos_x));
pos_y = Math.max(buffer, Math.min(1.0f - buffer, pos_y));
TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length];
builder.setTexture( ico );
builder.setCustomUv( s.getSide().getOpposite(), 0, 0, 16, 16 );
TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length];
builder.setTexture(ico);
builder.setCustomUv(s.getSide().getOpposite(), 0, 0, 16, 16);
switch( s.getSide() )
{
case UP:
offset = 1.0f - offset;
builder.addQuad( Direction.DOWN, pos_x - buffer, offset, pos_y - buffer,
pos_x + buffer, offset, pos_y + buffer );
break;
switch (s.getSide()) {
case UP:
offset = 1.0f - offset;
builder.addQuad(Direction.DOWN, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset,
pos_y + buffer);
break;
case DOWN:
builder.addQuad( Direction.UP, pos_x - buffer, offset, pos_y - buffer,
pos_x + buffer, offset, pos_y + buffer );
break;
case DOWN:
builder.addQuad(Direction.UP, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset,
pos_y + buffer);
break;
case EAST:
offset = 1.0f - offset;
builder.addQuad( Direction.WEST, offset, pos_x - buffer, pos_y - buffer,
offset, pos_x + buffer, pos_y + buffer );
break;
case EAST:
offset = 1.0f - offset;
builder.addQuad(Direction.WEST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
pos_y + buffer);
break;
case WEST:
builder.addQuad( Direction.EAST, offset, pos_x - buffer, pos_y - buffer,
offset, pos_x + buffer, pos_y + buffer );
break;
case WEST:
builder.addQuad(Direction.EAST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
pos_y + buffer);
break;
case SOUTH:
offset = 1.0f - offset;
builder.addQuad( Direction.NORTH, pos_x - buffer, pos_y - buffer, offset,
pos_x + buffer, pos_y + buffer, offset );
break;
case SOUTH:
offset = 1.0f - offset;
builder.addQuad(Direction.NORTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
pos_y + buffer, offset);
break;
case NORTH:
builder.addQuad( Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset,
pos_x + buffer, pos_y + buffer, offset );
break;
case NORTH:
builder.addQuad(Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
pos_y + buffer, offset);
break;
default:
}
}
default:
}
}
return builder.getOutput();
}
return builder.getOutput();
}
@Override
public boolean isAmbientOcclusion()
{
return false;
}
@Override
public boolean isAmbientOcclusion() {
return false;
}
@Override
public boolean isGui3d()
{
return true;
}
@Override
public boolean isGui3d() {
return true;
}
@Override
public boolean isBuiltInRenderer()
{
return false;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.textures[0];
}
@Override
public TextureAtlasSprite getParticleTexture() {
return this.textures[0];
}
@Override
public ItemOverrideList getOverrides()
{
return ItemOverrideList.EMPTY;
}
@Override
public ItemOverrideList getOverrides() {
return ItemOverrideList.EMPTY;
}
@Override
public boolean func_230044_c_() {
return false;
}
@Override
public boolean func_230044_c_() {
return false;
}
static List<Material> getRequiredTextures()
{
return ImmutableList.of(
TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3 );
}
static List<Material> getRequiredTextures() {
return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
}
}
@@ -1,30 +1,31 @@
package appeng.block.paint;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel> {
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, ResourceLocation modelLocation) {
return new PaintSplotchesBakedModel(spriteGetter);
}
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel>
{
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
return new PaintSplotchesBakedModel( spriteGetter );
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return PaintSplotchesBakedModel.getRequiredTextures();
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return PaintSplotchesBakedModel.getRequiredTextures();
}
}