Skip to content

Commit

Permalink
stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Dec 1, 2024
1 parent f7f1b6f commit 2e0bab5
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.leclowndu93150.carbort.content.blockentities;

import com.leclowndu93150.carbort.Carbort;
import com.leclowndu93150.carbort.api.blockentities.ContainerBlockEntity;
import com.leclowndu93150.carbort.api.capabilities.IOActions;
import com.leclowndu93150.carbort.registries.CBBlockEntities;
import com.leclowndu93150.carbort.utils.ClientUtils;
import it.unimi.dsi.fastutil.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -28,6 +28,11 @@ public void commonTick() {
float actualSpeed = getSpeed();
chasingVelocity += ((actualSpeed * 10 / 3f) - chasingVelocity) * .25f;
independentAngle += chasingVelocity;

if (level.isClientSide()) {
ClientUtils.spawnBreakParticles(worldPosition.below(), level.getBlockState(worldPosition.below()));
ClientUtils.shakeCamera();
}
}

private float getSpeed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.leclowndu93150.carbort.registries.CBBlockEntities;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.leclowndu93150.carbort.content.items;

import com.leclowndu93150.carbort.api.items.SimpleEnergyItem;

public class ShrinkinatorItem extends SimpleEnergyItem {
public ShrinkinatorItem(Properties properties) {
super(properties);
}

@Override
public int getEnergyUsage() {
return 0;
}

@Override
public int getCapacity() {
return 1000;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.leclowndu93150.carbort.events;

import com.leclowndu93150.carbort.Carbort;
import com.leclowndu93150.carbort.mixins.CameraMixin;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.util.RandomSource;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;

@EventBusSubscriber(modid = Carbort.MODID, value = Dist.CLIENT)
public class ClientCarbortEvents {
@SubscribeEvent
public static void renderLevel(RenderLevelStageEvent event) {
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) {
Camera camera = event.getCamera();
CameraMixin camera1 = (CameraMixin) camera;
RandomSource randomSource = Minecraft.getInstance().player.getRandom();
camera1.callSetRotation(camera.getYRot()+ randomSource.nextInt(5), camera.getXRot() + randomSource.nextInt(5), 5);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
package com.leclowndu93150.carbort.events;

import com.leclowndu93150.carbort.Carbort;
import com.leclowndu93150.carbort.capabilties.ItemStackEnergyStorage;
import com.leclowndu93150.carbort.content.items.HealingAxeItem;
import com.leclowndu93150.carbort.api.items.IEnergyItem;
import com.leclowndu93150.carbort.content.items.UnstableIngotItem;
import com.leclowndu93150.carbort.content.screen.ChunkAnalyzerScreen;
import com.leclowndu93150.carbort.networking.ChunkAnalyzerDataPayload;
import com.leclowndu93150.carbort.networking.ChunkAnalyzerTogglePayload;
import com.leclowndu93150.carbort.networking.PayloadActions;
import com.leclowndu93150.carbort.registries.CBDataComponents;
import com.leclowndu93150.carbort.registries.CBMenus;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.network.registration.PayloadRegistrar;

import static com.leclowndu93150.carbort.content.items.UnstableIngotItem.DAMAGE_CALCULATOR;

@EventBusSubscriber(modid = Carbort.MODID)
public class CarbortEvents {
public class CommonCarbortEvents {

@SubscribeEvent(priority = EventPriority.LOW)
public static void healingAxeHitEntity(AttackEntityEvent event) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/leclowndu93150/carbort/mixins/CameraMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.leclowndu93150.carbort.mixins;

import net.minecraft.client.Camera;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(Camera.class)
public interface CameraMixin {
@Invoker
void callSetRotation(float yRot, float xRot, float roll);

@Invoker
void callSetPosition(double x, double y, double z);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public final class CBItems {

public static final DeferredItem<PartyPickaxeItem> PARTY_PICKAXE = ITEMS.register("party_pickaxe", () -> new PartyPickaxeItem(new Item.Properties()));
public static final DeferredItem<Item> BEAN_WAND = ITEMS.register("bean_wand", () -> new Item(new Item.Properties()));
public static final DeferredItem<Item> SHRINKINATOR = ITEMS.register("shrinkinator", () -> new Item(new Item.Properties()));
public static final DeferredItem<ShrinkinatorItem> SHRINKINATOR = ITEMS.register("shrinkinator", () -> new ShrinkinatorItem(new Item.Properties()
.stacksTo(1)
.rarity(Rarity.RARE)
.component(CBDataComponents.ENERGY_STORAGE, 0)));
public static final DeferredItem<HealingAxeItem> HEALING_AXE = ITEMS.register("healing_axe", () -> new HealingAxeItem(new Item.Properties()));
public static final DeferredItem<ChunkAnalyzerItem> CHUNK_ANALYZER = ITEMS.register("chunk_analyzer",
() -> new ChunkAnalyzerItem(new Item.Properties()
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/leclowndu93150/carbort/utils/ClientUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.leclowndu93150.carbort.utils;

import com.leclowndu93150.carbort.mixins.CameraMixin;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
import net.neoforged.neoforge.client.event.RenderPlayerEvent;

public class ClientUtils {
public static void spawnBreakParticles(BlockPos pos, BlockState state) {
Minecraft.getInstance().particleEngine.destroy(pos, state);
}

public static void shakeCamera() {
Minecraft minecraft = Minecraft.getInstance();
Camera camera = minecraft.getEntityRenderDispatcher().camera;
CameraMixin cameraMixin = (CameraMixin) camera;
RandomSource random = minecraft.player.getRandom();
cameraMixin.callSetPosition(0, 10, 0);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/carbort.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_21",
"client": [
"CameraMixin",
"ItemInHandRendererMixin"
]
}

0 comments on commit 2e0bab5

Please sign in to comment.