com.parzivail.util.block.VerticalSlabBlock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pswg Show documentation
Show all versions of pswg Show documentation
Explore the galaxy with Galaxies: Parzi's Star Wars Mod!
package com.parzivail.util.block;
import net.minecraft.block.*;
import net.minecraft.class_10;
import net.minecraft.class_1657;
import net.minecraft.class_1750;
import net.minecraft.class_1799;
import net.minecraft.class_1922;
import net.minecraft.class_1936;
import net.minecraft.class_2248;
import net.minecraft.class_2338;
import net.minecraft.class_2350;
import net.minecraft.class_2350.class_2351;
import net.minecraft.class_259;
import net.minecraft.class_265;
import net.minecraft.class_2680;
import net.minecraft.class_2689;
import net.minecraft.class_2741;
import net.minecraft.class_2746;
import net.minecraft.class_2754;
import net.minecraft.class_2771;
import net.minecraft.class_3486;
import net.minecraft.class_3610;
import net.minecraft.class_3611;
import net.minecraft.class_3612;
import net.minecraft.class_3726;
import net.minecraft.class_3737;
import net.minecraft.class_4970;
import org.jetbrains.annotations.Nullable;
public class VerticalSlabBlock extends class_2248 implements class_3737
{
public static final class_2754 AXIS = class_2741.field_12496;
public static final class_2754 TYPE = class_2741.field_12485;
public static final class_2746 WATERLOGGED = class_2741.field_12508;
protected static final class_265 BOTTOM_SHAPE = class_2248.method_9541(0.0, 0.0, 0.0, 16.0, 8.0, 16.0);
protected static final class_265 TOP_SHAPE = class_2248.method_9541(0.0, 8.0, 0.0, 16.0, 16.0, 16.0);
protected static final class_265 NORTH_SHAPE = class_2248.method_9541(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 8.0D);
protected static final class_265 SOUTH_SHAPE = class_2248.method_9541(0.0D, 0.0D, 8.0D, 16.0D, 16.0D, 16.0D);
protected static final class_265 EAST_SHAPE = class_2248.method_9541(8.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);
protected static final class_265 WEST_SHAPE = class_2248.method_9541(0.0D, 0.0D, 0.0D, 8.0D, 16.0D, 16.0D);
public VerticalSlabBlock(class_4970.class_2251 settings)
{
super(settings);
this.method_9590(this.method_9564().method_11657(TYPE, class_2771.field_12681).method_11657(AXIS, class_2350.class_2351.field_11052).method_11657(WATERLOGGED, Boolean.FALSE));
}
@Override
public boolean method_9526(class_2680 state)
{
return state.method_11654(TYPE) != class_2771.field_12682;
}
@Override
protected void method_9515(class_2689.class_2690 builder)
{
builder.method_11667(TYPE, AXIS, WATERLOGGED);
}
@Override
public class_265 method_9530(class_2680 state, class_1922 world, class_2338 pos, class_3726 context)
{
var slabType = state.method_11654(TYPE);
switch (state.method_11654(AXIS))
{
case field_11048:
switch (slabType)
{
case field_12679:
return EAST_SHAPE;
case field_12681:
return WEST_SHAPE;
}
case field_11052:
switch (slabType)
{
case field_12679:
return TOP_SHAPE;
case field_12681:
return BOTTOM_SHAPE;
}
case field_11051:
switch (slabType)
{
case field_12679:
return SOUTH_SHAPE;
case field_12681:
return NORTH_SHAPE;
}
default:
return class_259.method_1077();
}
}
@Nullable
@Override
public class_2680 method_9605(class_1750 ctx)
{
var blockPos = ctx.method_8037();
var blockState = ctx.method_8045().method_8320(blockPos);
if (blockState.method_27852(this))
{
return blockState.method_11657(TYPE, class_2771.field_12682).method_11657(AXIS, blockState.method_11654(AXIS)).method_11657(WATERLOGGED, Boolean.FALSE);
}
else
{
var fluidState = ctx.method_8045().method_8316(blockPos);
var blockState2 = this.method_9564().method_11657(TYPE, class_2771.field_12681).method_11657(AXIS, class_2350.class_2351.field_11052).method_11657(WATERLOGGED, fluidState.method_15772() == class_3612.field_15910);
var direction = ctx.method_8038();
if (ctx.method_8036() != null && ctx.method_8036().method_5715())
{
if (direction != class_2350.field_11033 && direction != class_2350.field_11036)
{
// Place horizontal slab adjacent to a block
return ctx.method_17698().field_1351 - (double)blockPos.method_10264() > 0.5 ? blockState2.method_11657(TYPE, class_2771.field_12679) : blockState2;
}
else
{
// Place vertical slab above or below block
var playerLookDir = class_2350.method_10150(ctx.method_8044());
var axis = playerLookDir.method_10166();
var half = class_2771.field_12681;
switch (axis)
{
case field_11048 -> half = (ctx.method_17698().field_1352 - (double)blockPos.method_10263() > 0.5) ? class_2771.field_12679 : class_2771.field_12681;
case field_11051 -> half = (ctx.method_17698().field_1350 - (double)blockPos.method_10260() > 0.5) ? class_2771.field_12679 : class_2771.field_12681;
}
return this.method_9564().method_11657(TYPE, half).method_11657(AXIS, axis).method_11657(WATERLOGGED, fluidState.method_15772() == class_3612.field_15910);
}
}
else
{
return switch (direction)
{
case field_11043 -> blockState2.method_11657(TYPE, class_2771.field_12679).method_11657(AXIS, class_2350.class_2351.field_11051);
case field_11035 -> blockState2.method_11657(TYPE, class_2771.field_12681).method_11657(AXIS, class_2350.class_2351.field_11051);
case field_11034 -> blockState2.method_11657(TYPE, class_2771.field_12681).method_11657(AXIS, class_2350.class_2351.field_11048);
case field_11039 -> blockState2.method_11657(TYPE, class_2771.field_12679).method_11657(AXIS, class_2350.class_2351.field_11048);
case field_11033 -> blockState2.method_11657(TYPE, class_2771.field_12679).method_11657(AXIS, class_2350.class_2351.field_11052);
default -> blockState2;
};
}
}
}
@Override
public boolean method_9616(class_2680 state, class_1750 context)
{
var itemStack = context.method_8041();
var slabType = state.method_11654(TYPE);
var axis = state.method_11654(AXIS);
if (itemStack.method_7909() == (this).method_8389())
{
var direction = context.method_8038();
if (axis == class_2350.class_2351.field_11052)
{
return switch (slabType)
{
case field_12681 -> direction == class_2350.field_11036;
case field_12679 -> direction == class_2350.field_11033;
default -> false;
};
}
if (axis == class_2350.class_2351.field_11048)
{
return switch (slabType)
{
case field_12681 -> direction == class_2350.field_11034;
case field_12679 -> direction == class_2350.field_11039;
default -> false;
};
}
if (axis == class_2350.class_2351.field_11051)
{
return switch (slabType)
{
case field_12681 -> direction == class_2350.field_11035;
case field_12679 -> direction == class_2350.field_11043;
default -> false;
};
}
else
{
return false;
}
}
else
{
return false;
}
}
@Override
public class_3610 method_9545(class_2680 state)
{
return state.method_11654(WATERLOGGED) ? class_3612.field_15910.method_15729(false) : super.method_9545(state);
}
@Override
public boolean method_10311(class_1936 world, class_2338 pos, class_2680 state, class_3610 fluidState)
{
return state.method_11654(TYPE) != class_2771.field_12682 && class_3737.super.method_10311(world, pos, state, fluidState);
}
@Override
public boolean method_10310(@Nullable class_1657 player, class_1922 world, class_2338 pos, class_2680 state, class_3611 fluid)
{
return state.method_11654(TYPE) != class_2771.field_12682 && class_3737.super.method_10310(player, world, pos, state, fluid);
}
@Override
public class_2680 method_9559(class_2680 state, class_2350 direction, class_2680 neighborState, class_1936 world, class_2338 pos, class_2338 neighborPos)
{
if (state.method_11654(WATERLOGGED))
world.method_39281(pos, class_3612.field_15910, class_3612.field_15910.method_15789(world));
return super.method_9559(state, direction, neighborState, world, pos, neighborPos);
}
@Override
public boolean method_9516(class_2680 state, class_1922 world, class_2338 pos, class_10 type)
{
switch (type)
{
case field_48:
return world.method_8316(pos).method_15767(class_3486.field_15517);
default:
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy