use of net.minecraft.item.AliasedBlockItem in project meteor-client by MeteorDevelopment.
the class ItemPhysics method onRenderItemEntity.
@EventHandler
private void onRenderItemEntity(RenderItemEntityEvent event) {
ItemStack itemStack = event.itemEntity.getStack();
int seed = itemStack.isEmpty() ? 187 : Item.getRawId(itemStack.getItem()) + itemStack.getDamage();
event.random.setSeed(seed);
event.matrixStack.push();
BakedModel bakedModel = event.itemRenderer.getModel(itemStack, event.itemEntity.world, null, 0);
boolean hasDepthInGui = bakedModel.hasDepth();
int renderCount = getRenderedAmount(itemStack);
IItemEntity rotator = (IItemEntity) event.itemEntity;
boolean renderBlockFlat = false;
if (event.itemEntity.getStack().getItem() instanceof BlockItem && !(event.itemEntity.getStack().getItem() instanceof AliasedBlockItem)) {
Block b = ((BlockItem) event.itemEntity.getStack().getItem()).getBlock();
VoxelShape shape = b.getOutlineShape(b.getDefaultState(), event.itemEntity.world, event.itemEntity.getBlockPos(), ShapeContext.absent());
if (shape.getMax(Direction.Axis.Y) <= .5)
renderBlockFlat = true;
}
Item item = event.itemEntity.getStack().getItem();
if (item instanceof BlockItem && !(item instanceof AliasedBlockItem) && !renderBlockFlat) {
event.matrixStack.translate(0, -0.06, 0);
}
if (!renderBlockFlat) {
event.matrixStack.translate(0, .185, .0);
event.matrixStack.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(1.571F));
event.matrixStack.translate(0, -.185, -.0);
}
boolean isAboveWater = event.itemEntity.world.getBlockState(event.itemEntity.getBlockPos()).getFluidState().getFluid().isIn(FluidTags.WATER);
if (!event.itemEntity.isOnGround() && (!event.itemEntity.isSubmergedInWater() && !isAboveWater)) {
// calculate rotation based on age and ticks
float rotation = ((float) event.itemEntity.getItemAge() + event.tickDelta) / 20.0F + event.itemEntity.uniqueOffset;
if (!renderBlockFlat) {
event.matrixStack.translate(0, .185, .0);
event.matrixStack.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(rotation));
event.matrixStack.translate(0, -.185, .0);
rotator.setRotation(new Vec3d(0, 0, rotation));
} else {
event.matrixStack.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(rotation));
rotator.setRotation(new Vec3d(0, rotation, 0));
event.matrixStack.translate(0, -.065, 0);
}
if (event.itemEntity.getStack().getItem() instanceof AliasedBlockItem) {
event.matrixStack.translate(0, 0, .195);
} else if (!(event.itemEntity.getStack().getItem() instanceof BlockItem)) {
event.matrixStack.translate(0, 0, .195);
}
} else if (event.itemEntity.getStack().getItem() instanceof AliasedBlockItem) {
event.matrixStack.translate(0, .185, .0);
event.matrixStack.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion((float) rotator.getRotation().z));
event.matrixStack.translate(0, -.185, .0);
event.matrixStack.translate(0, 0, .195);
} else if (renderBlockFlat) {
event.matrixStack.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion((float) rotator.getRotation().y));
event.matrixStack.translate(0, -.065, 0);
} else {
if (!(event.itemEntity.getStack().getItem() instanceof BlockItem)) {
event.matrixStack.translate(0, 0, .195);
}
event.matrixStack.translate(0, .185, .0);
event.matrixStack.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion((float) rotator.getRotation().z));
event.matrixStack.translate(0, -.185, .0);
}
if (event.itemEntity.world.getBlockState(event.itemEntity.getBlockPos()).getBlock().equals(Blocks.SOUL_SAND)) {
event.matrixStack.translate(0, 0, -.1);
}
if (event.itemEntity.getStack().getItem() instanceof BlockItem) {
if (((BlockItem) event.itemEntity.getStack().getItem()).getBlock() instanceof SkullBlock) {
event.matrixStack.translate(0, .11, 0);
}
}
float scaleX = bakedModel.getTransformation().ground.scale.getX();
float scaleY = bakedModel.getTransformation().ground.scale.getY();
float scaleZ = bakedModel.getTransformation().ground.scale.getZ();
float x;
float y;
if (!hasDepthInGui) {
float r = -0.0F * (float) (renderCount) * 0.5F * scaleX;
x = -0.0F * (float) (renderCount) * 0.5F * scaleY;
y = -0.09375F * (float) (renderCount) * 0.5F * scaleZ;
event.matrixStack.translate(r, x, y);
}
for (int u = 0; u < renderCount; ++u) {
event.matrixStack.push();
if (u > 0) {
if (hasDepthInGui) {
x = (event.random.nextFloat() * 2.0F - 1.0F) * 0.15F;
y = (event.random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float z = (event.random.nextFloat() * 2.0F - 1.0F) * 0.15F;
event.matrixStack.translate(x, y, z);
} else {
x = (event.random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
y = (event.random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
event.matrixStack.translate(x, y, 0.0D);
event.matrixStack.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(event.random.nextFloat()));
}
}
event.itemRenderer.renderItem(itemStack, ModelTransformation.Mode.GROUND, false, event.matrixStack, event.vertexConsumerProvider, event.light, OverlayTexture.DEFAULT_UV, bakedModel);
event.matrixStack.pop();
if (!hasDepthInGui) {
event.matrixStack.translate(0.0F * scaleX, 0.0F * scaleY, 0.0625F * scaleZ);
}
}
event.matrixStack.pop();
event.setCancelled(true);
}
use of net.minecraft.item.AliasedBlockItem in project Terracraft by SimplyCmd.
the class ItemRegistry method register.
public static void register() {
magic_mirror = new SimpleItem(ID("magic_mirror"), new MirrorItem(new FabricItemSettings().group(ItemGroup.MISC).maxCount(1))).defaultItemModel();
grenade = new SimpleItem(ID("grenade"), new GrenadeThrowableItem(new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
flaming_arrow = new SimpleItem(ID("flaming_arrow"), new FlamingArrowItem()).defaultItemModel();
soul_fire_arrow = new SimpleItem(ID("soul_fire_arrow"), new FlamingArrowItem()).defaultItemModel();
slap_hand = new SimpleItem(ID("slap_hand"), new SlapHandItem()).defaultItemModel();
wand_of_sparking = new SimpleItem(ID("wand_of_sparking"), new WandOfSparkingItem(new FabricItemSettings().group(ItemGroup.COMBAT).maxCount(1).maxDamage(250))).defaultItemModel();
heart = new SimpleItem(ID("heart"), new HeartItem()).defaultItemModel();
umbrella = new SimpleItem(ID("umbrella"), new UmbrellaItem());
sickle = new SimpleItem(ID("sickle"), new SickleItem()).defaultItemModel();
daybloom = new SimpleItem(ID("daybloom"), new Item(new FabricItemSettings().group(ItemGroup.MATERIALS)));
daybloom_seeds = new SimpleItem(ID("daybloom_seeds"), new AliasedBlockItem(BlockRegistry.daybloom.getBlock(), new FabricItemSettings().group(ItemGroup.MISC)));
blue_berries = new SimpleItem(ID("blue_berries"), new AliasedBlockItem(BlockRegistry.blue_berry_bush.getBlock(), new FabricItemSettings().group(ItemGroup.MISC)));
platinum_coin = new SimpleItem(ID("platinum_coin"), new CoinItem(new Value(1, 0, 0, 0), null)).defaultItemModel();
gold_coin = new SimpleItem(ID("gold_coin"), new CoinItem(new Value(0, 1, 0, 0), ItemRegistry.platinum_coin.getItem())).defaultItemModel();
silver_coin = new SimpleItem(ID("silver_coin"), new CoinItem(new Value(0, 0, 1, 0), ItemRegistry.gold_coin.getItem())).defaultItemModel();
copper_coin = new SimpleItem(ID("copper_coin"), new CoinItem(new Value(0, 0, 0, 1), ItemRegistry.silver_coin.getItem())).defaultItemModel();
cactus_helmet = new SimpleItem(ID("cactus_helmet"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_chestplate = new SimpleItem(ID("cactus_chestplate"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.CHEST, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_leggings = new SimpleItem(ID("cactus_leggings"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.LEGS, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_boots = new SimpleItem(ID("cactus_boots"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_sword = new SimpleItem(ID("cactus_sword"), new SwordItem(ToolMaterials.CACTUS, 3, -2.4F, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
cactus_shovel = new SimpleItem(ID("cactus_shovel"), new ShovelItem(ToolMaterials.CACTUS, 1.5F, -3.0F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
cactus_pickaxe = new SimpleItem(ID("cactus_pickaxe"), new PickaxeItem(ToolMaterials.CACTUS, 1, -2.8F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
cactus_axe = new SimpleItem(ID("cactus_axe"), new AxeItem(ToolMaterials.CACTUS, 6.0F, -3.2F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
cactus_hoe = new SimpleItem(ID("cactus_hoe"), new HoeItem(ToolMaterials.CACTUS, 0, -3.0F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
}
Aggregations