Skip to content

Commit

Permalink
merge fixy
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm236 committed Jan 14, 2025
1 parent b52c6a9 commit 6779d7c
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod_group_id=net.jcm
mod_authors=Jcm, Brickyboy
mod_description=Adds Valkyrien Skies compat to Cosmic Horizons, as well as space-focused blocks for VS ships. [WIP]

cosmos_version=0.0.7.3
cosmos_version=0.0.7.2
vs2_mc_version=120
#vs2_version=2.5.0-beta.1+a81efdff02
#vs_core_version=1.1.0+cf7b0d3c5b
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/jcm/vsch/blocks/VSCHBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

import net.jcm.vsch.VSCHMod;

import net.jcm.vsch.blocks.custom.AirThrusterBlock;
import net.jcm.vsch.blocks.custom.DragInducerBlock;
import net.jcm.vsch.blocks.custom.GravityInducerBlock;
import net.jcm.vsch.blocks.custom.MagnetBlock;
import net.jcm.vsch.blocks.custom.PowerfulThrusterBlock;
import net.jcm.vsch.blocks.custom.ThrusterBlock;
import net.jcm.vsch.blocks.custom.*;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -52,6 +47,11 @@ public class VSCHBlocks {
.strength(5f)
.noOcclusion()));

public static final RegistryObject<Block> DOCKER_BLOCK = registerBlock("dock",
() -> new DockerBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(SoundType.COPPER)
.strength(5f)
.noOcclusion()));

/*public static final RegistryObject<Block> MAGNET_BLOCK = registerBlock("magnet_block",
() -> new MagnetBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(SoundType.COPPER)
.strength(5f)
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/net/jcm/vsch/blocks/custom/DockerBlock.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
package net.jcm.vsch.blocks.custom;

import net.jcm.vsch.blocks.entity.DockerBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class DockerBlock extends Block {
public class DockerBlock extends Block implements EntityBlock {
public DockerBlock(Properties properties) {
super(properties);
}

@Override
public @Nullable BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new DockerBlockEntity(blockPos,blockState);
}

@Override
public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return level.isClientSide() ? ((level0, pos0, state0, be) -> ((DockerBlockEntity) be).clientTick(level0, pos0, state0, (DockerBlockEntity) be)) : ((level0, pos0, state0, be) -> ((DockerBlockEntity) be).serverTick(level0, pos0, state0, (DockerBlockEntity) be));
}
}
20 changes: 17 additions & 3 deletions src/main/java/net/jcm/vsch/blocks/entity/DockerBlockEntity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package net.jcm.vsch.blocks.entity;

import net.jcm.vsch.blocks.entity.template.ParticleBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;

public class DockerBlockEntity extends BlockEntity {
public class DockerBlockEntity extends BlockEntity{

public DockerBlockEntity(BlockEntityType<?> pType, BlockPos pPos, BlockState pBlockState) {
super(pType, pPos, pBlockState);
public DockerBlockEntity(BlockPos pPos, BlockState pBlockState) {
super(VSCHBlockEntities.DOCKER_BLOCK_ENTITY.get(), pPos, pBlockState);
}

public void clientTick(Level level, BlockPos pos, BlockState state, DockerBlockEntity be) {

}

public void serverTick(Level level, BlockPos pos, BlockState state, DockerBlockEntity be) {
HitResult hitResult = level.clip(new ClipContext(pos.getCenter(),pos.getCenter().add(new Vec3(0,10,0)),ClipContext.Block.COLLIDER,ClipContext.Fluid.NONE,null));
System.out.println(hitResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class VSCHBlockEntities {
() -> BlockEntityType.Builder.of(GravityInducerBlockEntity::new, VSCHBlocks.GRAVITY_INDUCER_BLOCK.get())
.build(null));

public static final RegistryObject<BlockEntityType<DockerBlockEntity>> DOCKER_BLOCK_ENTITY =
BLOCK_ENTITIES.register("dock",
() -> BlockEntityType.Builder.of(DockerBlockEntity::new, VSCHBlocks.DOCKER_BLOCK.get())
.build(null));



public static void register(IEventBus eventBus) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/net/jcm/vsch/mixin/MixinAerialLightRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.jcm.vsch.mixin;

import net.lointain.cosmos.procedures.AerialLightRenderer;
import net.minecraftforge.fml.loading.FMLEnvironment;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(AerialLightRenderer.class)
public abstract class MixinAerialLightRenderer {

// getPrivateField fails when Cosmos is de-obfuscated in a dev enviroment, so this is here to stop that
@ModifyVariable(method = "getPrivateField", at = @At("HEAD"), argsOnly = true)
private static String fixFieldName(String fieldName) {

// Check if we are dev enviroment or obf enviroment
if (!FMLEnvironment.production) {
if (fieldName.equals("f_110009_")) {
return "passes";
}
if (fieldName.equals("f_110054_")) {
return "effect";
}
}

return fieldName;
}

}
26 changes: 26 additions & 0 deletions src/main/java/net/jcm/vsch/util/VSCHUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,32 @@ public static boolean isCollidingWithPlanet(@Nonnull CompoundTag planetData, Vec
return (distanceSqrX <= range && distanceSqrY <= range && distanceSqrZ <= range);
}

/**
* DEPRECATED, will crash on cosmic horizons 0.7.2+
*
* Gets all landing locations available from a planet and gives them to the entry_world global variable.
* @param world The LevelAccessor to get the cosmos world variables from
* @param target_planet The CompoundTag of the planet you are entering
*/
@Deprecated(forRemoval = true)
public static void setEntryLocations(LevelAccessor world, CompoundTag target_planet) {
WorldVariables worldVars = CosmosModVariables.WorldVariables.get(world);

Tag travel_to = target_planet.get("travel_to");

String travel_to_str = "";
if (travel_to instanceof StringTag _stringTag) {
travel_to_str = _stringTag.getAsString();
}
Tag locations = (worldVars.antena_locations.get(travel_to_str));
if (locations instanceof ListTag _listTag) {
worldVars.entry_world = _listTag;
worldVars.syncData(world);
} else {
logger.error("[VSCH:VSCHUtils:396] Locations were not ListTags, travel_to was possibly empty");
return;
}
}

/**
* Gets a players Cosmos variables capability, or if it doesn't exist, creates a new one.
Expand Down

0 comments on commit 6779d7c

Please sign in to comment.