Skip to content

Commit

Permalink
fixes and optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Jun 11, 2024
1 parent e6c614c commit b69dc72
Show file tree
Hide file tree
Showing 31 changed files with 6,927 additions and 6,839 deletions.
12,935 changes: 6,468 additions & 6,467 deletions src/main/generated/.cache/97a4721ed155c6fdfa3ad558e447c8340a205f56

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21 Pre-Release 3 2024-06-10T00:13:35.9478522 Extravaganza!/Language (en_us)
75fbb3bf2fef742445d19535da9f8c92f1a44be6 assets\extravaganza\lang\en_us.json
// 1.21 Release Candidate 1 2024-06-11T20:24:08.0816653 Extravaganza!/Language (en_us)
6ef37e2cdcc172a3e835e91ec18b2a4ea8fb9589 assets\extravaganza\lang\en_us.json
1 change: 1 addition & 0 deletions src/main/generated/assets/extravaganza/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@
"block.extravaganza.orange_wooded_festive_rubber_slab": "Orange Wooded Festive Rubber Slab",
"block.extravaganza.orange_wooded_festive_rubber_stairs": "Orange Wooded Festive Rubber Stairs",
"block.extravaganza.orange_wooded_festive_rubber_wall": "Orange Wooded Festive Rubber Wall",
"block.extravaganza.pinata": "Pinata",
"block.extravaganza.pink_barred_festive_rubber": "Pink Barred Festive Rubber",
"block.extravaganza.pink_barred_festive_rubber_slab": "Pink Barred Festive Rubber Slab",
"block.extravaganza.pink_barred_festive_rubber_stairs": "Pink Barred Festive Rubber Stairs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "extravaganza:block/ball_pool_content"
}
"parent": "extravaganza:block/ball_pool_content"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "extravaganza:block/pinata"
}
11 changes: 1 addition & 10 deletions src/main/java/com/mmodding/extravaganza/Extravaganza.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class Extravaganza implements ModInitializer {

public static final List<String> COLOR_QUALIFIERS = List.of(
"black", "blue", "brown", "cyan",
"gray", "green", "light_blue", "light_gray",
"lime", "magenta", "orange", "pink",
"purple", "red", "white", "yellow",
"plant", "tomato", "tear", "nymph" // ModFest Carnival Colors
);

private static final Logger LOGGER = LoggerFactory.getLogger("extravaganza");

@Override
Expand All @@ -35,7 +26,7 @@ public void onInitialize() {
ExtravaganzaEntities.register();
ExtravaganzaGameRules.register();
ExtravaganzaItems.register();
ExtravaganzaParticles.register();
ExtravaganzaParticleTypes.register();
}

public static Logger getLogger() {
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/mmodding/extravaganza/ExtravaganzaColor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.mmodding.extravaganza;

import com.mmodding.extravaganza.entity.FestiveBallEntity;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.util.StringIdentifiable;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.List;

public enum ExtravaganzaColor implements StringIdentifiable {

BLACK, BLUE, BROWN, CYAN,
GRAY, GREEN, LIGHT_BLUE, LIGHT_GRAY,
LIME, MAGENTA, ORANGE, PINK,
PURPLE, RED, WHITE, YELLOW,
PLANT, TOMATO, TEAR, NYMPH; // ModFest Carnival Colors

public static final List<ExtravaganzaColor> VALUES = Arrays.stream(ExtravaganzaColor.values()).toList();

public static ExtravaganzaColor fromString(@NotNull String identifier) {
return ExtravaganzaColor.valueOf(identifier.toUpperCase());
}

@Override
public String asString() {
return this.name().toLowerCase();
}

public ItemStack createBallStack() {
return Registries.ITEM.get(Extravaganza.createId(this.asString() + "_festive_ball")).getDefaultStack();
}

public FestiveBallEntity createBallEntity(World world, Entity owner) {
return new FestiveBallEntity(this, world, owner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.block.*;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.ModelIds;
import net.minecraft.data.client.Models;
import net.minecraft.item.BlockItem;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -62,7 +63,8 @@ public static class ExtravaganzaModelProvider extends FabricModelProvider {
block instanceof TransparentBlock ||
block instanceof LadderBlock ||
block.equals(ExtravaganzaBlocks.BALL_POOL_CORE) ||
block.equals(ExtravaganzaBlocks.BALL_POOL_CONTENT);
block.equals(ExtravaganzaBlocks.BALL_POOL_CONTENT) ||
block.equals(ExtravaganzaBlocks.PINATA);

private ExtravaganzaModelProvider(FabricDataOutput output) {
super(output);
Expand All @@ -88,8 +90,8 @@ else if (block instanceof LadderBlock) {
blockStateModelGenerator.registerNorthDefaultHorizontalRotation(block);
blockStateModelGenerator.registerItemModel(block);
}
else if (block.equals(ExtravaganzaBlocks.BALL_POOL_CONTENT)) {
blockStateModelGenerator.registerItemModel(block);
else if (block.equals(ExtravaganzaBlocks.BALL_POOL_CONTENT) || block.equals(ExtravaganzaBlocks.PINATA)) {
blockStateModelGenerator.registerParentedItemModel(block, ModelIds.getBlockModelId(block));
}
});
}
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/com/mmodding/extravaganza/block/PinataBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.mmodding.extravaganza.block;

import com.mojang.serialization.MapCodec;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;

public class PinataBlock extends HorizontalFacingBlock {

public static final MapCodec<PinataBlock> CODEC = PinataBlock.createCodec(PinataBlock::new);

public PinataBlock(Settings settings) {
super(settings);
}

@Override
protected MapCodec<? extends HorizontalFacingBlock> getCodec() {
return PinataBlock.CODEC;
}

@Override
protected boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return Block.sideCoversSmallSquare(world, pos.up(), Direction.DOWN) && !world.isWater(pos);
}

@Override
protected BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
return direction == Direction.UP && !this.canPlaceAt(state, world, pos)
? Blocks.AIR.getDefaultState()
: super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.getDefaultState().with(FACING, ctx.getHorizontalPlayerFacing().getOpposite());
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mmodding.extravaganza.client;

import com.mmodding.extravaganza.client.init.ExtravaganzaModelLayers;
import com.mmodding.extravaganza.client.init.ExtravaganzaParticles;
import com.mmodding.extravaganza.client.init.ExtravaganzaRenderLayers;
import com.mmodding.extravaganza.client.init.ExtravaganzaRenderers;
import net.fabricmc.api.ClientModInitializer;
Expand All @@ -10,6 +11,7 @@ public class ExtravaganzaClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ExtravaganzaModelLayers.register();
ExtravaganzaParticles.register();
ExtravaganzaRenderers.register();
ExtravaganzaRenderLayers.register();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
import com.mmodding.extravaganza.client.entity.model.FestiveBallEntityModel;
import com.mmodding.extravaganza.client.init.ExtravaganzaModelLayers;
import com.mmodding.extravaganza.entity.FestiveBallEntity;
import com.mmodding.extravaganza.init.ExtravaganzaEntities;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;

import java.util.function.Function;

public class FestiveBallEntityRenderer extends EntityRenderer<FestiveBallEntity> {

private final FestiveBallEntityModel model;
Expand All @@ -25,59 +22,7 @@ public FestiveBallEntityRenderer(EntityRendererFactory.Context ctx) {

@Override
public Identifier getTexture(FestiveBallEntity entity) {
Function<String, Identifier> factory = color -> Extravaganza.createId("textures/entity/festive_ball/" + color + ".png");
// fuck you java for not allowing me to do a switch
if (entity.getType().equals(ExtravaganzaEntities.BLACK_FESTIVE_BALL)) {
return factory.apply("black");
}
else if (entity.getType().equals(ExtravaganzaEntities.BLUE_FESTIVE_BALL)) {
return factory.apply("blue");
}
else if (entity.getType().equals(ExtravaganzaEntities.BROWN_FESTIVE_BALL)) {
return factory.apply("brown");
}
else if (entity.getType().equals(ExtravaganzaEntities.CYAN_FESTIVE_BALL)) {
return factory.apply("cyan");
}
else if (entity.getType().equals(ExtravaganzaEntities.GRAY_FESTIVE_BALL)) {
return factory.apply("gray");
}
else if (entity.getType().equals(ExtravaganzaEntities.GREEN_FESTIVE_BALL)) {
return factory.apply("green");
}
else if (entity.getType().equals(ExtravaganzaEntities.LIGHT_BLUE_FESTIVE_BALL)) {
return factory.apply("light_blue");
}
else if (entity.getType().equals(ExtravaganzaEntities.LIGHT_GRAY_FESTIVE_BALL)) {
return factory.apply("light_gray");
}
else if (entity.getType().equals(ExtravaganzaEntities.LIME_FESTIVE_BALL)) {
return factory.apply("lime");
}
else if (entity.getType().equals(ExtravaganzaEntities.MAGENTA_FESTIVE_BALL)) {
return factory.apply("magenta");
}
else if (entity.getType().equals(ExtravaganzaEntities.ORANGE_FESTIVE_BALL)) {
return factory.apply("orange");
}
else if (entity.getType().equals(ExtravaganzaEntities.PINK_FESTIVE_BALL)) {
return factory.apply("pink");
}
else if (entity.getType().equals(ExtravaganzaEntities.PURPLE_FESTIVE_BALL)) {
return factory.apply("purple");
}
else if (entity.getType().equals(ExtravaganzaEntities.RED_FESTIVE_BALL)) {
return factory.apply("red");
}
else if (entity.getType().equals(ExtravaganzaEntities.WHITE_FESTIVE_BALL)) {
return factory.apply("white");
}
else if (entity.getType().equals(ExtravaganzaEntities.YELLOW_FESTIVE_BALL)) {
return factory.apply("yellow");
}
else {
return null;
}
return Extravaganza.createId("textures/entity/festive_ball/" + entity.getColor().asString() + ".png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mmodding.extravaganza.client.init;

import com.mmodding.extravaganza.client.particle.ConfettiParticle;
import com.mmodding.extravaganza.init.ExtravaganzaParticleTypes;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;

public class ExtravaganzaParticles {

public static void register() {
ParticleFactoryRegistry.getInstance().register(ExtravaganzaParticleTypes.CONFETTI, ConfettiParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(ExtravaganzaParticleTypes.CONFETTI_SHAKE, ConfettiParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(ExtravaganzaParticleTypes.CONFETTI_SHATTER, ConfettiParticle.Factory::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ExtravaganzaRenderLayers {
public static void register() {
Extravaganza.executeKeyForRegistry(Registries.BLOCK, key -> {
Predicate<String> checker = word -> key.getValue().getPath().contains(word);
if (checker.test("grate") || checker.test("windowed") || checker.test("ladder")) {
if (checker.test("pinata") || checker.test("grate") || checker.test("windowed") || checker.test("ladder")) {
BlockRenderLayerMap.INSTANCE.putBlock(Registries.BLOCK.get(key), RenderLayer.getCutout());
}
else if(checker.test("stained")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@
public class ExtravaganzaRenderers {

public static void register() {
EntityRendererRegistry.register(ExtravaganzaEntities.BLACK_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.BLUE_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.BROWN_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.CYAN_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.GRAY_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.GREEN_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.LIGHT_BLUE_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.LIGHT_GRAY_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.LIME_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.MAGENTA_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.ORANGE_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.PINK_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.PURPLE_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.RED_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.WHITE_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.YELLOW_FESTIVE_BALL, FestiveBallEntityRenderer::new);
EntityRendererRegistry.register(ExtravaganzaEntities.FESTIVE_BALL, FestiveBallEntityRenderer::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mmodding.extravaganza.client.particle;

import com.mmodding.extravaganza.init.ExtravaganzaParticleTypes;
import com.mmodding.extravaganza.particle.ConfettiParticleEffect;
import net.minecraft.client.particle.*;
import net.minecraft.client.world.ClientWorld;

public class ConfettiParticle extends AscendingParticle {

protected ConfettiParticle(ClientWorld world, double x, double y, double z, float randomVelocityXMultiplier, float randomVelocityYMultiplier, float randomVelocityZMultiplier, double velocityX, double velocityY, double velocityZ, float scaleMultiplier, SpriteProvider spriteProvider, float colorMultiplier, int baseMaxAge, float gravityStrength, boolean collidesWithWorld) {
super(world, x, y, z, randomVelocityXMultiplier, randomVelocityYMultiplier, randomVelocityZMultiplier, velocityX, velocityY, velocityZ, scaleMultiplier, spriteProvider, colorMultiplier, baseMaxAge, gravityStrength, collidesWithWorld);
}

public static class Factory implements ParticleFactory<ConfettiParticleEffect> {

private final SpriteProvider spriteProvider;

public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}

public Particle createParticle(ConfettiParticleEffect effect, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i) {
float multiplier;
if (effect.getType().equals(ExtravaganzaParticleTypes.CONFETTI_SHAKE)) {
multiplier = 0.6f;
}
else if (effect.getType().equals(ExtravaganzaParticleTypes.CONFETTI_SHATTER)) {
multiplier = 0.3f;
}
else {
multiplier = 0.1f;
}
ConfettiParticle particle = new ConfettiParticle(clientWorld, d, e, f, multiplier, multiplier, multiplier, 0.0f, 0.0f, 0.0f, 1.0f, this.spriteProvider, 1.0f, 30, 0.1f, true);
particle.setAlpha(effect.getAlpha());
particle.setColor(effect.getRed(), effect.getGreen(), effect.getBlue());
return particle;
}
}
}
Loading

0 comments on commit b69dc72

Please sign in to comment.